public abstract classFileStoreextendsObject
FileStore represents a storage pool, device, partition, volume, concrete file system or other implementation specific means of file storage. TheFileStore for where a file is stored is obtained by invoking thegetFileStore method, or all file stores can be enumerated by invoking thegetFileStores method. In addition to the methods defined by this class, a file store may support one or moreFileStoreAttributeView classes that provide a read-only or updatable view of a set of file store attributes.
| Modifier | Constructor | Description |
|---|---|---|
protected | FileStore() | Initializes a new instance of this class. |
| Modifier and Type | Method | Description |
|---|---|---|
abstractObject | getAttribute(String attribute) | Reads the value of a file store attribute. |
abstract <V extendsFileStoreAttributeView> | getFileStoreAttributeView(Class<V> type) | Returns a FileStoreAttributeView of the given type. |
abstract long | getTotalSpace() | Returns the size, in bytes, of the file store. |
abstract long | getUnallocatedSpace() | Returns the number of unallocated bytes in the file store. |
abstract long | getUsableSpace() | Returns the number of bytes available to this Java virtual machine on the file store. |
abstract boolean | isReadOnly() | Tells whether this file store is read-only. |
abstractString | name() | Returns the name of this file store. |
abstract boolean | supportsFileAttributeView(Class<? extendsFileAttributeView> type) | Tells whether or not this file store supports the file attributes identified by the given file attribute view. |
abstract boolean | supportsFileAttributeView(String name) | Tells whether or not this file store supports the file attributes identified by the given file attribute view. |
abstractString | type() | Returns thetype of this file store. |
public abstract String name()
The string returned by this method may differ from the string returned by thetoString method.
public abstract String type()
public abstract boolean isReadOnly()
IOException to be thrown.true if, and only if, this file store is read-onlypublic abstract long getTotalSpace() throwsIOException
IOException - if an I/O error occurspublic abstract long getUsableSpace() throwsIOException
The returned number of available bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of usable bytes is most likely to be accurate immediately after the space attributes are obtained. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this Java virtual machine.
IOException - if an I/O error occurspublic abstract long getUnallocatedSpace() throwsIOException
The returned number of unallocated bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after the space attributes are obtained. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine.
IOException - if an I/O error occurspublic abstract boolean supportsFileAttributeView(Class<? extendsFileAttributeView> type)
Invoking this method to test if the file store supportsBasicFileAttributeView will always returntrue. In the case of the default provider, this method cannot guarantee to give the correct result when the file store is not a local storage device. The reasons for this are implementation specific and therefore unspecified.
type - the file attribute view typetrue if, and only if, the file attribute view is supportedpublic abstract boolean supportsFileAttributeView(String name)
Invoking this method to test if the file store supportsBasicFileAttributeView, identified by the name "basic" will always returntrue. In the case of the default provider, this method cannot guarantee to give the correct result when the file store is not a local storage device. The reasons for this are implementation specific and therefore unspecified.
name - thename of file attribute viewtrue if, and only if, the file attribute view is supportedpublic abstract <V extendsFileStoreAttributeView> V getFileStoreAttributeView(Class<V> type)
FileStoreAttributeView of the given type. This method is intended to be used where the file store attribute view defines type-safe methods to read or update the file store attributes. Thetype parameter is the type of the attribute view required and the method returns an instance of that type if supported.
V - TheFileStoreAttributeView typetype - theClass object corresponding to the attribute viewnull if the attribute view is not availablepublic abstract Object getAttribute(String attribute) throwsIOException
Theattribute parameter identifies the attribute to be read and takes the form:
view-name:attribute-namewhere the character
':' stands for itself.view-name is thename of aAttributeView that identifies a set of file attributes.attribute-name is the name of the attribute.
Usage Example: Suppose we want to know if ZFS compression is enabled (assuming the "zfs" view is supported):
boolean compression = (Boolean)fs.getAttribute("zfs:compression");attribute - the attribute to readnull may be a valid valid for some attributesUnsupportedOperationException - if the attribute view is not available or it does not support reading the attributeIOException - if an I/O error occurs