See More

------------------------ Path | ------------------------ # ÊÇÒ»¸ö½Ó¿Ú,jdk1.7µÄж«Î÷ # ±íʾһ¸öÎļþ»òÕßĿ¼,Ò²ÐíËü²»´æÔÚ # ¹¹Ôì(ÈýÖÖ·½Ê½) 1, FileSystems ¾²Ì¬·½·¨ Path path = FileSystems.getDefault().getPath("F:/test/jdk7", "test.txt"); 2,ͨ¹ý File ¶ÔÏó»ñÈ¡ File file = new File("F:/test/jdk7/test.txt"); Path path = file.toPath(); 3,Paths ¾²Ì¬·½·¨ Path path = Paths.get("F:/test/jdk7", "test.txt"); * µÚ¶þ¸ö²ÎÊýÊǿɱ䳤²ÎÊý,±êʶ²ã¼¶Ä¿Â¼ ------------------------ Path-ʵÀý·½·¨ | ------------------------ boolean endsWith(Path other) boolean endsWith(String other) * ÊÇ·ñÒÔÖ¸¶¨µÄÐÎʽ½áβ boolean startsWith(Path other) boolean startsWith(String other) * ÊÇ·ñÒÔÖ¸¶¨µÄÐÎʽ½áβ boolean isAbsolute(); * ÅжÏÊÇ·ñ²»ÊǾø¶Ô·¾¶ Iterator iterator(); * ·µ»Øµü´úÆ÷ * δ֪ Path resolve(Path path); Path resolve(String path); * Èç¹û²ÎÊýÊǾø¶Ô·¾¶,¾Í·µ»Ø²ÎÊý,²»È»·µ»Øµ±Ç°¶ÔÏó+²ÎÊý·¾¶µÄ¶ÔÏó Path resolveSibling(Path path); Path resolveSibling(String path); * Èç¹û path ÊǾø¶Ô·¾¶,¾Í·µ»Øpath±íʾµÄ¶ÔÏó * ²»È»·µ»Ø this µÄ¸¸Â·¾¶ + path ±íʾµÄ·¾¶¶ÔÏó Path relativize(Path path); * ʹÓà this ½øÐнâÎö,Ï൱ÓÚµÄ path µÄ·¾¶ Path normalize(); * ɾ³ýһЩ·ûºÅ[.],[..] * ÈßÓàµÄ·¾¶±íÊ¾ÔªËØ Path toAbsolutePath(); * ·µ»Ø¾ø¶Ô·¾¶ File toFile(); * ת»»Îªfile¶ÔÏó URI toUri(); * ת»»ÎªURI int compareTo(Path path) * ÅжÏÁ½¸öÎļþ¶ÔÏóÊÇ·ñÏàͬ int getNameCount(); * »ñÈ¡ÎļþËùÔڵĽڵã²ãÊý,¿ÉÒÔÀí½âΪÔÚĿ¼µÄµÚ¼¸²ãÁË Path getFileName(); * »ñȡ·¾¶ÖÐÎļþµÄÃû³Æ Path getRoot(); * ·µ»Ø¸ùĿ¼,Èç¹ûûÓиùĿ¼,·µ»Ønull FileSystem getFileSystem(); * »ñÈ¡Îļþϵͳ¶ÔÏó Path getParent(); * »ñÈ¡µ±Ç°PathµÄ¸¸¼¶path Path getName(int x ); * »ñȡָ¶¨²ã´ÎµÄPath¶ÔÏó * Èç¹û³¬¹ýÁË»òÕßΪ¸ºÊý,»áÅ׳öÒì³£ Path subpath(int beginIndex,int endIndex); * »ñÈ¡×Ó·¾¶µÄPath * demo Path path = Paths.get("E:\\ext-6.2.0\\index.html"); System.out.println(path.subpath(1, 2)); //index.html Path toAbsolutePath(); * ת»»Îª¾ø¶Ô·¾¶ Path toRealPath(LinkOption... options); * »ñÈ¡ÕæÊµÂ·¾¶ Spliterator path.spliterator(); * δ֪ WatchKey register(WatchService watcher,WatchEvent.Kind>... events) * °ó¶¨¼àÌý ------------------------ Path-¾²Ì¬·½·¨ | ------------------------