java中path环境变量怎么配置_javapath

java中path环境变量怎么配置_javapath0、说明用于读Path操作的接口(Path)与实现类(Paths)1、模块:java.nio.file.Path、java.nio.file.Paths2、方法2.1、Paths只有两个静态方法,用法:Paths.xxx(…)Pathget(Stringfirst,St

大家好,欢迎来到IT知识分享网。

0、说明

用于读Path操作的接口(Path)与实现类(Paths)

1、模块:java.nio.file.Path、java.nio.file.Paths

2、方法

2.1、Paths

只有两个静态方法,用法:Paths.xxx( … )

Path get( String first , String… more )

连接符把这些参数中的String连接起来,得到一个对应的Path(和Path.of( … )相同

Windows中的连接符是\

Path get( URI uri ) 将一个给定的URI转化为Path对象

2.2、Path

2.2.1、静态方法,用法:Path.xxx( … )

Path of( String first , String… more)

与Paths.get(…)作用相同

返回一个Path对象

Path of( URI uri )

2.2.2、实例方法,用法:p.xxx( … )

返回值类型

方法

说明

int compareTo(Path other) 比较两个Path
boolean endsWith(String other) 判断该Path是否以other结尾
boolean endsWith(Path other) 判断该Path是否以另一个Path结尾
boolean equals(Object other) 判断该Path是否和另一个元素相等
Path getFileName() 文件名对应的Path
FileSystem getFileSystem() 返回构造了这个Path的文件系统
Path getName(int index)

返回Path某一级目录的名字

比如 usr\Docs\Test,对应0/1/2分别是usr、Docs、Test

int getNameCount() 返回Path目录有几级,常配合getName(int index)使用
Path getParent() 获取父目录的Path
Path getRoot() 获取根目录的Path
int hashCode() hash code
boolean isAbsolute() 判断该Path是否是绝对路径
Iterator<Path> iterator() 实现迭代器,允许对Path[ ]使用for each遍历
Path normalize() 将路径正规化(即转换为不含.和..的绝对路径)
WatchKey register(WatchService watcher, WatchEvent.Kind<?>… events)  
WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier… modifiers)  
Path relativize(Path other) 返回两个路径间的相对路径
Path resolve(String other)

如果other是绝对路径,返回other;

如果other是null,返回this;

否则,在this之后拼接other形成新Path

Path resolve(Path other)
Path resolveSibling(String other)

如果other是绝对路径,返回other;

如果other是null,返回this;

否则,在this的父目录下拼接other形成新的Path

Path resolveSibling(Path other)
boolean startsWith(String other) 判断该Path是否以other开头
boolean startsWith(Path other) 判断该Path是否以other开头
Path subPath(int start , int end) 返回从start到end的subpath
Path toAbsolutePath() 返回绝对路径
File toFile() Path→File
Path toRealPath(LinkOption… options)  
String toString() 返回该Path对应的String
URI toUri() 返回该Path对应的URI

正规路径:不含.和..的绝对路径

3、方法说明

最常用:

Path→String:p.toString()

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/29474.html

(0)
上一篇 2023-10-03 22:15
下一篇 2023-10-04 20:15

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信