黑马程序员技术交流社区

标题: File()构造函数中的 抽象路径名 是什么意思啊 [打印本页]

作者: 刘勇强    时间: 2013-5-20 22:40
标题: File()构造函数中的 抽象路径名 是什么意思啊
本帖最后由 刘勇强 于 2013-5-21 12:02 编辑

public File(String parent,String child)

api文档中的:
If parent is the empty string then the new File instance is created by converting  child into an abstract pathname and resolving the result against a system-dependent default directory.
如果 parent是空字符串,child就被转换成抽象路径名(abstract pathname)来创建File的对象(instance)



看了半天,始终不理解这里用abstract这个概念是什么意思 或则起什么作用

其实后面还有一句:
Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.
分别把parent和child两个路径名转换为abstract pathname  




作者: 韩秀山    时间: 2013-5-20 22:46
老师说 这API写的不怎么样。呵呵,抽象这词可以跳过去,不看他!!

希望有知道的。我也想知道为什么???
作者: 黑马-许鹏    时间: 2013-5-20 22:50
抽象路径之相对于绝对路径来说的,比如说"c:\abc\a.txt"这就是个绝对路径,而"a.txt"就是个抽象的,它根据环境的不同而不同。构造函数中public File(String parent,String child)比如 File("c:\\abc","a.txt"),可以定义一个绝对路径的文件,如果File("","a.txt")就是相对的。希望对你有帮助!
作者: 刘勇强    时间: 2013-5-20 23:07
黑马-许鹏 发表于 2013-5-20 22:50
抽象路径之相对于绝对路径来说的,比如说"c:\abc\a.txt"这就是个绝对路径,而"a.txt"就是个抽象的,它根据 ...

相对路径也是相对于绝对路径来说的,那么抽象路径跟相对路径有什么区别呢?

根据环境不同而不同怎么理解,是指不同的系统环境吗?比如windows或linux
作者: 刘勇强    时间: 2013-5-21 11:12
顶上来 看看有没有回答




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2