List of usage examples for java.nio.file Files isSymbolicLink
public static boolean isSymbolicLink(Path path)
From source file:Test.java
public static void main(String[] args) throws Exception { Path file = Paths.get("/opt/platform/java"); if (Files.isSymbolicLink(file)) { file = Files.readSymbolicLink(file); }/*from w w w . ja v a2 s . c om*/ Files.readAttributes(file, BasicFileAttributes.class); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path path = FileSystems.getDefault().getPath("/home/docs/users.txt"); System.out.println(Files.isSymbolicLink(path)); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path path1 = Paths.get("/home/docs/users.txt"); Path path2 = Paths.get("/home/music/users.txt"); System.out.println(Files.isSymbolicLink(path1)); System.out.println(Files.isSymbolicLink(path2)); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path path1 = Paths.get("/home/docs/users.txt"); Path path2 = Paths.get("/home/music/users.txt"); System.out.println(Files.isSymbolicLink(path1)); System.out.println(Files.isSymbolicLink(path2)); Path path = Paths.get(new URI("C:/home/./music/users.txt")); System.out.println("Normalized: " + path.normalize()); System.out.println("Absolute path: " + path.toAbsolutePath()); System.out.println("URI: " + path.toUri()); System.out.println("toRealPath (Do not follow links): " + path.toRealPath(LinkOption.NOFOLLOW_LINKS)); System.out.println("toRealPath: " + path.toRealPath()); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path path = FileSystems.getDefault().getPath("./file2.log"); System.out.println("File Size:" + Files.size(path)); System.out.println("Is Directory:" + Files.isDirectory(path)); System.out.println("Is Regular File:" + Files.isRegularFile(path)); System.out.println("Is Symbolic Link:" + Files.isSymbolicLink(path)); System.out.println("Is Hidden:" + Files.isHidden(path)); System.out.println("Last Modified Time:" + Files.getLastModifiedTime(path)); System.out.println("Owner:" + Files.getOwner(path)); DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class); System.out.println("Archive :" + view.readAttributes().isArchive()); System.out.println("Hidden :" + view.readAttributes().isHidden()); System.out.println("Read-only:" + view.readAttributes().isReadOnly()); System.out.println("System :" + view.readAttributes().isSystem()); view.setHidden(false);/*from w w w . j a v a 2s .c o m*/ }
From source file:Test.java
private static void displayFileAttributes(Path path) throws Exception { String format = "Exists: %s %n" + "notExists: %s %n" + "Directory: %s %n" + "Regular: %s %n" + "Executable: %s %n" + "Readable: %s %n" + "Writable: %s %n" + "Hidden: %s %n" + "Symbolic: %s %n" + "Last Modified Date: %s %n" + "Size: %s %n"; System.out.printf(format, Files.exists(path, LinkOption.NOFOLLOW_LINKS), Files.notExists(path, LinkOption.NOFOLLOW_LINKS), Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS), Files.isRegularFile(path, LinkOption.NOFOLLOW_LINKS), Files.isExecutable(path), Files.isReadable(path), Files.isWritable(path), Files.isHidden(path), Files.isSymbolicLink(path), Files.getLastModifiedTime(path, LinkOption.NOFOLLOW_LINKS), Files.size(path)); }
From source file:org.flowerplatform.core.CoreUtils.java
public static void delete(File f) { if (f.isDirectory() && !Files.isSymbolicLink(Paths.get(f.toURI()))) { for (File c : f.listFiles()) { delete(c);// w ww . j ava 2 s. co m } } f.delete(); }
From source file:controller.FileWatcher.java
@Override public void onDirectoryCreate(File arg0) { // TODO Auto-generated method stub if (!Files.isSymbolicLink(arg0.toPath())) { String directoryName = ServerUtil.convertPath(arg0.getAbsolutePath(), MyDropboxSwing.urls); String log = "Directory is created " + arg0.getName() + "\n"; System.out.println(log);/*from w w w . j ava 2 s .com*/ jTextArea1.append(log); FileCreate fileCreate = new FileCreate(directoryName, Constants.IS_FOLDER); lstCommit.add(fileCreate); } }
From source file:org.foi.uzdiz.jFS.VFSNodes.VFSDirectory.java
private void internalInit(File directory) throws IOException, Exception { File[] fList = directory.listFiles(); for (File f : fList) { String fileParts[] = f.getName().split("\\."); if (fileParts.length > 1) { // TODO: support case --> ivan.pusic.txt if (fileParts[0].length() > VFS.maxFileNameLength) { VFS.hasBrokenFiles = true; continue; }/*from w w w. ja v a 2s . c o m*/ if (fileParts[1].length() > VFS.maxFileExtLength) { VFS.hasBrokenFiles = true; continue; } } if (f.isFile()) { if (Files.isSymbolicLink(f.toPath())) { addNode(new VFSSymFile(f, this)); } else { addNode(new VFSFile(f, this)); } } else if (f.isDirectory()) { if (Files.isSymbolicLink(f.toPath())) { addNode(new VFSSymDirectory(f, this)); } else { addNode(new VFSDirectory(f, this, false)); } } else { addNode(new VFSBroken(f, this)); } } }
From source file:com.blackducksoftware.ohcount4j.FileFinder.java
private boolean canAddDirectoryForProcessing(File directory) { boolean isSymbolicLink = Files.isSymbolicLink(directory.toPath()); if (isSymbolicLink) { return processSymbolicLinks; } else {/* w ww . j a va2 s.c o m*/ return true; } }