- 定义基本路径
//定义基本路径 Path path01 = Paths.get("/cn/icer/ws/client/Business.java"); Path path02 = Paths.get("F:/cn/icer/ws/client/Business.java");
- Equal
//First Method if (path01.equals(path02)) { System.out.println("The paths are equal!"); } else { System.out.println("The paths are not equals!"); }
- isSameFile
//Second Method try { boolean check = Files.isSameFile(path01, path02); if (check) { System.out.println("The paths locate the same file!"); } else { System.out.println("The paths does not locate the same file!"); } } catch (Exception e) { e.printStackTrace(); }
- compateTo
//Third Method int compare = path01.compareTo(path02); System.out.println(compare);
- startsWith and endsWith
//Fourth Method boolean sw = path01.startsWith("/cn/icer/ws/client"); System.out.println(sw); boolean ew = path01.endsWith("Business.java"); System.out.println(ew);