- java.lang.Object
-
- java.nio.file.FileStore
-
public abstract class FileStore extends Object
Storage for files. AFileStore
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 more
FileStoreAttributeView
classes that provide a read-only or updatable view of a set of file store attributes.- Since:
- 1.7
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
FileStore()
Initializes a new instance of this class.
-
Method Summary
Methods Modifier and Type Method and Description abstract Object
getAttribute(String attribute)
Reads the value of a file store attribute.abstract <V extends FileStoreAttributeView>
VgetFileStoreAttributeView(Class<V> type)
Returns aFileStoreAttributeView
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.abstract String
name()
Returns the name of this file store.abstract boolean
supportsFileAttributeView(Class<? extends FileAttributeView> 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.abstract String
type()
Returns the type of this file store.
-
-
-
Method Detail
-
name
public abstract String name()
Returns the name of this file store. The format of the name is highly implementation specific. It will typically be the name of the storage pool or volume.The string returned by this method may differ from the string returned by the
toString
method.- Returns:
- the name of this file store
-
type
public abstract String type()
Returns the type of this file store. The format of the string returned by this method is highly implementation specific. It may indicate, for example, the format used or if the file store is local or remote.- Returns:
- a string representing the type of this file store
-
isReadOnly
public abstract boolean isReadOnly()
Tells whether this file store is read-only. A file store is read-only if it does not support write operations or other changes to files. Any attempt to create a file, open an existing file for writing etc. causes anIOException
to be thrown.- Returns:
true
if, and only if, this file store is read-only
-
getTotalSpace
public abstract long getTotalSpace() throws IOException
Returns the size, in bytes, of the file store.- Returns:
- the size of the file store, in bytes
- Throws:
IOException
- if an I/O error occurs
-
getUsableSpace
public abstract long getUsableSpace() throws IOException
Returns the number of bytes available to this Java virtual machine on the file store.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.
- Returns:
- the number of bytes available
- Throws:
IOException
- if an I/O error occurs
-
getUnallocatedSpace
public abstract long getUnallocatedSpace() throws IOException
Returns the number of unallocated bytes in the file store.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.
- Returns:
- the number of unallocated bytes
- Throws:
IOException
- if an I/O error occurs
-
supportsFileAttributeView
public abstract boolean supportsFileAttributeView(Class<? extends FileAttributeView> type)
Tells whether or not this file store supports the file attributes identified by the given file attribute view.Invoking this method to test if the file store supports
BasicFileAttributeView
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.- Parameters:
type
- the file attribute view type- Returns:
true
if, and only if, the file attribute view is supported
-
supportsFileAttributeView
public abstract boolean supportsFileAttributeView(String name)
Tells whether or not this file store supports the file attributes identified by the given file attribute view.Invoking this method to test if the file store supports
BasicFileAttributeView
, 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.- Parameters:
name
- thename
of file attribute view- Returns:
true
if, and only if, the file attribute view is supported
-
getFileStoreAttributeView
public abstract <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type)
Returns aFileStoreAttributeView
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. The
type
parameter is the type of the attribute view required and the method returns an instance of that type if supported.- Parameters:
type
- theClass
object corresponding to the attribute view- Returns:
- a file store attribute view of the specified type or
null
if the attribute view is not available
-
getAttribute
public abstract Object getAttribute(String attribute) throws IOException
Reads the value of a file store attribute.The
attribute
parameter identifies the attribute to be read and takes the form:view-name:attribute-name
where the character':'
stands for itself.view-name is the
name
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");
- Parameters:
attribute
- the attribute to read- Returns:
- the attribute value;
null
may be a valid valid for some attributes - Throws:
UnsupportedOperationException
- if the attribute view is not available or it does not support reading the attributeIOException
- if an I/O error occurs
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/nio/file/FileStore.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.