public abstract class FileStoreInfo extends Object
java.nio.file.FileStore class introduced in Java 7, but using reflection to
permit Java 6 to determine cleanly at runtime that file stores are not
supported.
TODO:
We no longer support Java 6 so much of this mechanism can be removed. Other
code can assume that a FileStore is always available. Also, if an
IOException is thrown by FileStore methods, instead of tolerating this we
should invalidate the Environment, since this is standard JE policy.
However, we may want to leave the factory interface in place to support
testing with arbitrary disk space limits.| Modifier and Type | Field and Description |
|---|---|
static String |
FILE_STORE_CLASS
The full name of the Java 7 FileStore class, which must be present for
this class to be supported.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FileStoreInfo()
Support subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkSupported()
Checks whether the current Java runtime supports providing information
about file stores.
|
static FileStoreInfo |
getInfo(String file)
Returns a
FileStoreInfo instance that provides information about
the file store associated with the specified file. |
abstract long |
getTotalSpace()
Returns the size, in bytes, of the file store.
|
abstract long |
getUsableSpace()
Returns the number of bytes available in the file store.
|
static void |
setFactory(com.sleepycat.je.utilint.FileStoreInfo.Factory factory)
For testing: specifies the factory, or null for the default.
|
public static final String FILE_STORE_CLASS
public static final void checkSupported()
UnsupportedOperationException.UnsupportedOperationException - if the current runtime does not
support file storespublic static void setFactory(com.sleepycat.je.utilint.FileStoreInfo.Factory factory)
public static FileStoreInfo getInfo(String file) throws IOException
FileStoreInfo instance that provides information about
the file store associated with the specified file. Throws UnsupportedOperationException if called on a Java runtime prior to Java
7. Equal objects will be returned for all files associated with the
same file store.file - the fileFileStoreInfoUnsupportedOperationException - if called on a Java runtime prior
to Java 7IllegalStateException - if an unexpected exception occurs when
attempting to use reflection to access the underlying implementationIOException - if an I/O error occurspublic abstract long getTotalSpace()
throws IOException
IOException - if an I/O error occurspublic abstract long getUsableSpace()
throws IOException
IOException - if an I/O error occursCopyright © 2024. All rights reserved.