測試代碼以下測試
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
運行結果