getPath()与getAbsolutePath()的区别

测试代码以下测试

public class TextPath {spa

public static void main(String[] args) {cdn

File file = new File("workspace\\test\\test1.txt"); blog

//取得相对路径get

System.out.println("Path: " + file.getPath()); it

//取得绝对路径io

System.out.println("getAbsolutePath: " + file.getAbsolutePath()); class

}test

}file

运行结果


相关文章
相关标签/搜索