Search code examples
javafilesystemspartitioningdiskvolumes

Java FileStore concept vs actual storage?


How do Java FileStore relates to other non Java concepts such as Device, Partition, File System, or Volume?

Not sure this is correct at all, especially when starting to read the definition:

public abstract class FileStore

Storage for files. A FileStore represents a storage pool, device, partition, volume, concrete file system or other implementation specific means of file storage.


Solution

  • Actually it's more abstract than that. A FileStore is

    The FileStore for where a file is stored is obtained by invoking the getFileStore method, or all file stores can be enumerated by invoking the getFileStores method.

    i.e. it is any store where you can get the contents of a file by name or list all the files.

    There is a built in implementation for the file systems e.g. a drive, but there is also one for ZIP/JAR files. You could write one for a FTP service.

    An in memory version would be a Map<String, FileContents> where you can look up content or get a list of names.