public interface Path
extends Comparable<Path>, Iterable<Path>, Watchable
1. A Path represents a path that is hierarchical and composed of a sequence of directory and file name elements separated by a special separator or delimiter. 2. A root component, that identifies a file system hierarchy, may also be present.
3. The name element that is farthest from the root of the directory hierarchy is the name of a file or directory. The other name elements are directory names.
4. A Path can represent a root, a root and a sequence of names, or simply one or more name elements.
5. A Path is considered to be an empty path if it consists solely of one name element that is empty.
6. Accessing a file using an empty path is equivalent to accessing the default directory of the file system.  method classify:
1.  Path defines the getFileNamegetParentgetRoot, and subpath methods to access the path components or a subsequence of its name elements.
2. In addition to accessing the components of a path, a Path also defines the resolve and resolveSibling methods to combine paths. 
3. The relativize method that can be used to construct a relative path between two paths. Paths can be compared,
and tested against each other using the startsWith and endWith methods.
4. This interface extends Watchable interface so that a directory located by a path can be registered with a WatchService and entries in the directory watched. accessing files:
1. Paths may be used with the Files class to operate on files, directories, and other types of files.
For example, suppose we want a BufferedReader to read text from a file "access.log".
The file is located in a directory "logs" relative to the current working directory and is UTF-8 encoded.
 Path path = FileSystems.getDefault().getPath("logs", "access.log");
BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
Interoperability:
1. The toPath method may be used to obtain a Path from the abstract path name represented by a java.io.File object.
  The resulting Path can be used to operate on the same file as the java.io.File object. 
2. In addition, the toFile method is useful to construct a File from the String representation of a Path.
concurrency:
Implementations of this interface are immutable and safe for use by multiple concurrent threads. method:
方法签名 意义
int compareTo(Path other)  按顺序比较两个路径
boolean endsWith(Path other)  测试一个Path对象是否以给定的path为结尾
boolean endsWith(String other)  测试一个Path对象是否以给定的字符串为结尾,字符串会转换为Path对象
boolean equals(Object other)  
Path getFileName()  
FileSystem getFileSystem()  返回创建Path对象的文件系统对象  
Path getName(int index)  以Path对象返回路径对象中一个名字组成
int getNameCount()  Returns the number of name elements in the path.
Path getParent()  Returns the parent path, or null if this path does not have a parent.
Path getRoot()  Returns the root component of this path as a Path object, or null if this path does not have a root component.
boolean isAbsolute()  Tells whether or not this path is absolute.
Iterator<Path>  iterator()  Returns an iterator over the name elements of this path.
Path normalize()  移除诸如. 和.. 等冗余的路径元素。

WatchKey

register(WatchService watcher, WatchEvent.Kind<?>... events)

 Registers the file located by this path with a watch service.
WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)  Registers the file located by this path with a watch service.
Path relativize(Path other)  返回用this 进行解析,相对于other 的相对路径。
Path resolve(Path other)  如果other 是绝对路径,那么就返回other ;否则,返回通过连接this 和other 获得的路径。
Path resolve(String other)  如果other 是绝对路径,那么就返回other ;否则,返回通过连接this 和other 获得的路径。
Path resolveSibling(Path other)  如果other 是绝对路径,那么就返回other ;否则,返回通过连接this 的父路径和other 获得的路径。
Path resolveSibling(String other)  如果other 是绝对路径,那么就返回other ;否则,返回通过连接this 的父路径和other 获得的路径。
boolean startsWith(Path other)  类似endsWith
boolean startsWith(String other)  类似endsWith
Path subpath(int beginIndex, int endIndex)  Returns a relative Path that is a subsequence of the name elements of this path.
Path toAbsolutePath()  Returns a Path object representing the absolute path of this path.
File toFile()  Returns a File object representing this path.
Path toRealPath(LinkOption... options)  Returns the real path of an existing file.
URI toUri()  Returns a URI to represent this path.

java.nio.file.Path的更多相关文章

  1. Java JsonPath grab InvalidPathException in code, you must be catching Java 7's java.nio.file.InvalidPathException instead of JsonPath's com.jayway.jsonpath.InvalidPathExceptio

    I am using JsonPath and am able to parse my data and get the values when the path provided is correc ...

  2. Java7 新特性 —— java.nio.file 文件操作

    本文部分摘自 On Java 8 自 Java7 开始,Java 终于简化了文件读写的基本操作,新增了 java.nio.file 库,通过与 Java8 新增的 stream 结合可以使得文件操作变 ...

  3. Docker启动Elasticsearch报错java.nio.file.AccessDeniedException

    报错信息 Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes 问题分析 表面上是说容 ...

  4. java.nio.file.FileSystemException: D:\kafka_2.12-2.1.0\kafka_2.12-2.1.0\logs\__consumer_offsets-30\00000000000000000000.timeindex.cleaned: 另一个程序正在使用此文件,进程无法访问。

    在启动kafka时候报错: java.nio.file.FileSystemException: D:\kafka_2.12-2.1.0\kafka_2.12-2.1.0\logs\__consume ...

  5. 使用java类加载器,报异常java.nio.file.InvalidPathException

    String path = Label.class.getClassLoader().getResource("").getPath(); /F:/idea-Java/ImageD ...

  6. java.nio.file.NoSuchFileException

    springboot +es es 2.1.0 参考这个 https://www.cnblogs.com/yueshutong/p/9381543.html cluster-nodes :改成127. ...

  7. kafka - java.nio.file.FileSystemException

    在启动Kafka时报错无法启动 E:\kafka_2.12-2.3.1\kafka-logs\__consumer_offsets-48\00000000000000000000.timeindex. ...

  8. 2.2.5 NIO.2 Path 和 Java 已有的 File 类

    NIO与IO交互 toPath() File -- Path toFile() Path -- File Demo: import java.io.File; import java.nio.file ...

  9. JAVA基础知识之NIO.2——Path,Paths,Files

    NIO.2 JDK7对NIO进行了重大改进,主要包含以下两方面 新增Path接口,Paths工具类,Files工具类. 这些接口和工具类对NIO中的功能进行了高度封装,大大简化了文件系统的IO编程. ...

随机推荐

  1. JAVA基本类库介绍

    我们曾经讲过,Java已经为编程者编制了许多类,这些类已经经过测试,基本上不存在错误,这些类都是我们编程的基础.如果不利用这些已存在的类,我们的 编程工作将变得异常复杂,所以我们应尽可能多的掌握Jav ...

  2. chkconfig命令详解

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法:chkconfig [--ad ...

  3. 【转】Delphi+Halcon实战一:两行代码识别QR二维码

    Delphi+Halcon实战一:两行代码识别QR二维码 感谢网友:绝代双椒( QQ号应原作者要求隐藏了:xxxx6348)的支持 本文是绝代双椒的作品,因为最近在忙zw量化培训,和ziwang.co ...

  4. WdatePicker 没有权限 不能执行已释放 Script 的代码

    提示 拒绝访问 或 没有权限 或 ' Window.document 或 '$dp' 为空或不是对象 $dp.dd is undefined 之类的错误 SCRIPT70: 没有权限 WdatePic ...

  5. 在Excel里用vba给合并的单元格添加注释

    Excel里使用VBA对已经合并的单元格添加注释,直接使用AddComment会报: 运行时错误 '1004':应用程序定义或者对象定义错误 找了很多文章都没找到怎么解决,最后发现在AddCommen ...

  6. quick-cocos2d-x :加入学习

    语法不熟悉, 接口不熟悉. 部分不理解. 超级初学者. 好好学习, 一直在学习 使用Quick-Cocos2d-x搭建一个横版过关游戏 推荐官方的文档和例子  demo

  7. .NET工程师技术进阶

    通常,一个人对技术的掌握程度可以分为精通.熟练.熟悉.了解,详细解析如下: 精通:能够掌握此技术的85%技术要点以上,使用此技术时间超过两年,并使用此技术成功实施5个以上的项目.能使用此技术优化性能或 ...

  8. C++11特性(模板类 initializer_list)

    [1]initializer_list模板类 C++primer 原文如下: 通读原文相关篇幅,分析解读内容如下: 提供initializer_list类的初衷,为了便于将有限个同一类型(或可转换为同 ...

  9. phpcms V9 内容模型管理

    [1]理解模型 模型,系统知识的抽象表示.既然抽象了,那就得脑补一下.大家都是面向对象设计的专业人员,类就很抽象的,对比类的定义想象一下模型的概念. 举个例子,一般新闻类的信息,都具有标题.内容.作者 ...

  10. redis 参考文章

    1. redis配置认证密码:http://blog.csdn.net/zyz511919766/article/details/42268219