File file = new File(".\\test.txt");
System.out.println(file.getPath());
System.out.println(file.getAbsolutePath());
System.out.println(file.getCanonicalPath());
返回的结果为:
.\test.txt
E:\workspace\Test\.\test.txt
E:\workspace\Test\test.txt
原文地址:http://handd.blog.51cto.com/2796632/1173823
本文详细解释了Java中File类的getPath(), getAbsolutePath(), 和 getCanonicalPath() 方法的功能,通过实例演示它们的区别,并提供了关键代码示例。
508

被折叠的 条评论
为什么被折叠?



