List of usage examples for java.nio.file FileSystems getDefault
public static FileSystem getDefault()
From source file:Main.java
public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); FileSystemProvider provider = fileSystem.provider(); System.out.println("Provider: " + provider.toString()); System.out.println("Open: " + fileSystem.isOpen()); System.out.println("Read Only: " + fileSystem.isReadOnly()); }
From source file:Main.java
public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); FileSystemProvider provider = fileSystem.provider(); Iterable<FileStore> fileStores = fileSystem.getFileStores(); System.out.println();//from w w w . j a v a 2 s. com System.out.println("File Stores"); for (FileStore fileStore : fileStores) { System.out.println(fileStore.name()); } }
From source file:Test.java
public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); FileSystemProvider provider = fileSystem.provider(); System.out.println("Provider: " + provider.toString()); System.out.println("Open: " + fileSystem.isOpen()); System.out.println("Read Only: " + fileSystem.isReadOnly()); Iterable<Path> rootDirectories = fileSystem.getRootDirectories(); System.out.println();//from www . jav a 2 s . c o m System.out.println("Root Directories"); for (Path path : rootDirectories) { System.out.println(path); } Iterable<FileStore> fileStores = fileSystem.getFileStores(); System.out.println(); System.out.println("File Stores"); for (FileStore fileStore : fileStores) { System.out.println(fileStore.name()); } }
From source file:Test.java
public static void main(String[] args) throws Exception { Path path = FileSystems.getDefault().getPath("/home/docs/users.txt"); DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class); DosFileAttributes attributes = view.readAttributes(); System.out.println("isArchive: " + attributes.isArchive()); System.out.println("isHidden: " + attributes.isHidden()); System.out.println("isReadOnly: " + attributes.isReadOnly()); System.out.println("isSystem: " + attributes.isSystem()); }
From source file:Main.java
public static void main(String[] args) throws IOException { FileSystem fileSystem = FileSystems.getDefault(); for (FileStore store : fileSystem.getFileStores()) { boolean supported = store.supportsFileAttributeView("basic"); System.out.println(store.name() + " ---" + supported); }/* w w w . j ava2 s. c o m*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { FileSystem fileSystem = FileSystems.getDefault(); for (FileStore store : fileSystem.getFileStores()) { FileStoreAttributeView fsav = store.getFileStoreAttributeView(FileStoreAttributeView.class); System.out.println(fsav); }//from w w w . j ava 2 s. c o m }
From source file:Main.java
public static void main(String[] args) throws IOException { FileSystem fileSystem = FileSystems.getDefault(); for (FileStore store : fileSystem.getFileStores()) { boolean supported = store.supportsFileAttributeView(BasicFileAttributeView.class); System.out.println(store.name() + " ---" + supported); }/* ww w.j av a 2 s . c o m*/ }
From source file:Test.java
public static void main(String[] args) throws Exception { Path path = FileSystems.getDefault().getPath("/home/docs/users.txt"); // BasicFileAttributes attributes = Files.readAttributes(path, // BasicFileAttributes.class); BasicFileAttributeView view = Files.getFileAttributeView(path, BasicFileAttributeView.class); BasicFileAttributes attributes = view.readAttributes(); System.out.println("Creation Time: " + attributes.creationTime()); System.out.println("Last Accessed Time: " + attributes.lastAccessTime()); System.out.println("Last Modified Time: " + attributes.lastModifiedTime()); System.out.println("File Key: " + attributes.fileKey()); System.out.println("Directory: " + attributes.isDirectory()); System.out.println("Other Type of File: " + attributes.isOther()); System.out.println("Regular File: " + attributes.isRegularFile()); System.out.println("Symbolic File: " + attributes.isSymbolicLink()); System.out.println("Size: " + attributes.size()); }
From source file:Main.java
public static void main(String[] args) throws IOException { UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService(); Path path = Paths.get("c:/"); Files.setOwner(path, lookupService.lookupPrincipalByName("joe")); }
From source file:Test.java
public static void main(String[] args) throws Exception { WatchService watcher = FileSystems.getDefault().newWatchService(); Path dir = FileSystems.getDefault().getPath("/usr/a"); WatchKey key = dir.register(watcher, ENTRY_MODIFY); while (true) { key = watcher.take();/*from w w w .jav a 2 s .co m*/ for (WatchEvent<?> event : key.pollEvents()) { if (event.kind() == ENTRY_MODIFY) { System.out.println("Home dir changed!"); } } key.reset(); } }