以下结果,一看便知
public static void test1(){
//1.txt 存放在当前目录即D:\workspace\test\
File file1 = new File("1.txt");
File file2 = new File("D:\\workspace\\test\\1.txt");
System.out.println(“getPath():"+file1.getPath());
System.out.println("getAbsolutePath:"+file1.getAbsolutePath());
System.out.println(file2.getPath());
System.out.println(file2.getAbsolutePath());
}
getPath():1.txt
getAbsolutePath:D:\workspace\test\1.txt
D:\workspace\test\1.txt
D:\workspace\test\1.txt |