List of usage examples for java.nio.file Paths get
public static Path get(URI uri)
From source file:Main.java
public static void main(String[] args) { //define the fix path Path base_1 = Paths.get("C:/tutorial/Java/JavaFX"); Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt"); //resolve sibling Demo.txt file Path path_3 = base_2.resolveSibling("Demo.txt"); System.out.println(path_3.toString()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path start = Paths.get("c:/Java_Dev/run.bat"); int maxDepth = 5; long fileCount = Files.walk(start, maxDepth).filter(path -> String.valueOf(path).endsWith("xls")).count(); System.out.format("XLS files found: %s", fileCount); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path start = Paths.get("c:/Java_Dev/"); int maxDepth = 5; Files.find(start, maxDepth, (path, attr) -> String.valueOf(path).endsWith("xls")).sorted() .forEach(System.out::println); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path path = Paths.get("users.txt"); System.out.println("Real path: " + path.toRealPath(LinkOption.NOFOLLOW_LINKS)); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path sourceFile = Paths.get("C:/home/docs/users.txt"); Files.move(sourceFile, sourceFile.resolveSibling(sourceFile.getFileName() + ".bak")); }
From source file:Main.java
public static void main(String[] args) { //define the fix path Path base_1 = Paths.get("C:/tutorial/Java/JavaFX"); Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt"); //resolve Topic.txt file Path path_1 = base_1.resolve("Topic.txt"); System.out.println(path_1.toString()); //resolve Demo.txt file Path path_2 = base_1.resolve("Demo.txt"); System.out.println(path_2.toString()); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path sourceFile = Paths.get("C:/home/docs/users.txt"); Path destinationFile = Paths.get("C:/home/music/users.txt"); Files.move(sourceFile, destinationFile); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path sourceFile = Paths.get("C:/home/docs"); Path destinationFile = Paths.get("C:/home/music/docs"); Files.move(sourceFile, destinationFile); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path existingFilePath = Paths.get("C:\\Java_Dev\\test1.txt"); Path symLinkPath = Paths.get("C:\\test1_link.txt"); Files.createSymbolicLink(symLinkPath, existingFilePath); }
From source file:Main.java
public static void main(String[] args) throws Exception { Path directoriesPath = Paths.get("C:/home/test/subtest/subsubtest"); Path testDirectory = Files.createDirectories(directoriesPath); System.out.println("Directory sequence created successfully!"); }