Java IO & NIO Java Java API
java.nio.file.Files
public static FileStore getFileStore(Path path) throws IOException
Returns the FileStore. A FileStore represents file store details where the file is located.
FileStore
path
package com.logicbig.example.files;import java.io.IOException;import java.nio.file.FileStore;import java.nio.file.Files;import java.nio.file.Path;public class GetFileStoreExample { public static void main(String... args) throws IOException { Path tempFile = Files.createTempFile("test-file", ".txt"); FileStore fileStore = Files.getFileStore(tempFile); System.out.println("total space: " + fileStore.getTotalSpace()); System.out.println("unallocated space: " + fileStore.getUnallocatedSpace()); System.out.println("usable space: " + fileStore.getUsableSpace()); System.out.println("store type: " + fileStore.type()); }}
total space: 142541602816unallocated space: 22585438208usable space: 22585438208store type: NTFS