OnJava8-Examples/files/FileSystemDemo.java

42 lines
1.3 KiB
Java
Raw Normal View History

// files/FileSystemDemo.java
2016-12-30 17:23:13 -08:00
// (c)2017 MindView LLC: see Copyright.txt
2015-12-02 09:20:27 -08:00
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
2015-12-02 09:20:27 -08:00
import java.nio.file.*;
public class FileSystemDemo {
2015-12-02 09:20:27 -08:00
static void show(String id, Object o) {
System.out.println(id + ": " + o);
}
public static void main(String[] args) {
System.out.println(System.getProperty("os.name"));
FileSystem fsys = FileSystems.getDefault();
for(FileStore fs : fsys.getFileStores())
show("File Store", fs);
for(Path rd : fsys.getRootDirectories())
show("Root Directory", rd);
show("Separator", fsys.getSeparator());
show("UserPrincipalLookupService",
fsys.getUserPrincipalLookupService());
show("isOpen", fsys.isOpen());
show("isReadOnly", fsys.isReadOnly());
show("FileSystemProvider", fsys.provider());
show("File Attribute Views",
fsys.supportedFileAttributeViews());
}
}
/* Output:
Windows 10
File Store: SSD (C:)
2015-12-02 09:20:27 -08:00
Root Directory: C:\
Root Directory: D:\
2015-12-02 09:20:27 -08:00
Separator: \
UserPrincipalLookupService:
sun.nio.fs.WindowsFileSystem$LookupService$1@15db9742
2015-12-02 09:20:27 -08:00
isOpen: true
isReadOnly: false
FileSystemProvider:
sun.nio.fs.WindowsFileSystemProvider@6d06d69c
2015-12-02 09:20:27 -08:00
File Attribute Views: [owner, dos, acl, basic, user]
*/