import java.nio.file.Path; import java.nio.file.Paths; public class NIODemo { public static void main(String[] args){ Path p1 = Paths.get("C:\\workspace\\test\\test1\\hello.text"); System.out.println("Get File Name: " + p1.getFileName()); System.out.println("Get Parent: " + p1.getParent()); System.out.println("Get Name Count: " + p1.getNameCount()); System.out.println("Get Root:" + p1.getRoot()); System.out.println("Is Absolute:" + p1.isAbsolute()); System.out.println("To Absolute Path:" + p1.toAbsolutePath()); System.out.println("To URI Path:" + p1.toUri()); } }
2015年10月12日 星期一
Java 檔案管理程式
NIO.2 基本應用: