Język

FileSystem.FileStores Property

Definition

Returns an object to iterate over the underlying file stores.

public abstract Java.Lang.IIterable? FileStores { [Android.Runtime.Register("getFileStores", "()Ljava/lang/Iterable;", "GetGetFileStoresHandler", ApiSince=26)] get; }
[<get: Android.Runtime.Register("getFileStores", "()Ljava/lang/Iterable;", "GetGetFileStoresHandler", ApiSince=26)>]
member this.FileStores : Java.Lang.IIterable

Property Value

An object to iterate over the backing file stores

Attributes

Remarks

Returns an object to iterate over the underlying file stores. The elements of the returned iterator are the FileStores for this file system. The order of the elements is not defined and the file stores may change during the lifetime of the Java virtual machine. When an I/O error occurs, perhaps because a file store is not accessible, then it is not returned by the iterator. In the case of the default provider, and a security manager is installed, the security manager is invoked to check RuntimePermission("getFileStoreAttributes"). If denied, then no file stores are returned by the iterator. In addition, the security manager's SecurityManager.checkRead(String) method is invoked to check read access to the file store's top-most directory. If denied, the file store is not returned by the iterator. It is system dependent if the permission checks are done when the iterator is obtained or during iteration.

for (FileStore store: FileSystems.getDefault().getFileStores()) {
    long total = store.getTotalSpace() / 1024;
    long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024;
    long avail = store.getUsableSpace() / 1024;
    System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail);
}

Java reference for java.nio.file.FileSystem.getFileStores.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to