java nio路径无法处理windows网络路径
为什么会发生这种情况
def path=java.nio.file.Paths.get("c:/kittuhomestore/Csmart/files/companies");
path.getNameCount();
4
def path=java.nio.file.Paths.get("//kittuhomestore/Csmart/files/companies");
path.getNameCount();
2
后者是windows共享网络驱动器
# 1 楼答案
输出:
在第一种情况下,路径的
Root
是C:\
,因此剩余部分是kittuhomestore
、Csmart
、files
和companies
,因此是4组件输出:
在第二种情况下,路径的
Root
是\\kittuhomestore\Csmart\
,因此剩余部分是files
和companies
,因此是2组件这是因为UNC path具有以下格式
其中
\\server\share
是路径的根