该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames.
When an abstract pathname is converted into a pathname string, each name is separated from the next by a single copy of the default separator character.
When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system.
看上边的三句话
第一句意思是说抽象路径名是和系统无关的
第二句意思是说抽象路径名转换成路径名时候,相邻的两个名字中间加入一个系统默认的分隔符
第三句意思是路径名转换成抽象路径名时候,路径名中的名字会被默认的分隔符,或者是底层系统支持的任意的分隔符分割
这里需要解释一下“名字”
假如有一个文件的路径为F:\Java\lib\jfr\profile.jrc
这里边“Java","lib","jfr","profile.jrc"都是名字
因此可以推断出,抽象路径名的第二部分(当然第一部分是F:\前缀)是由任意的分隔符(这分隔符有可能就是当前系统默认的分隔符,也可能是系统支持的任意的其它什么能作为分隔符使用的字符)分割的表示路径的字符串,有可能是“Java\lib\jfr\profile.jrc”,也有可能是“Java/lib/jfr/profile.jrc”,或者其它的什么吧。至于这个抽象的路径名是怎么做到和系统无关的呢,就是因为这个分隔符并没有实际的意义,而是在具体使用时候进行系统相关的转换,如果当前是Windows系统,就把路径的分隔符转换成'\',如果是Linux的,就转换成'/'。
这种抽象的目的就是为了保证系统无关,也就是根据不同的系统执行不同的转换操作。