檔案操作路徑區別
阿新 • • 發佈:2019-02-19
import java.io.*;
public class SL275
{
public static void main(String[] args)
{
try
{
File f=new File("C:\\Winnt\\test.txt");
System.out.println(f.getCanonicalPath());
System.out.println(f.getAbsolutePath());
System.out.println(f.getPath());
}
catch(IOException ioe)
{
}
}
}
輸出結果是:
C:\WINNT\test.txt
C:\Winnt\test.txt
C:\Winnt\test.txt
public class SL275
{
public static void main(String[] args)
{
try
{
File f=new File("C:\\Winnt\\test.txt");
System.out.println(f.getCanonicalPath());
System.out.println(f.getAbsolutePath());
System.out.println(f.getPath());
}
catch(IOException ioe)
{
}
}
}
輸出結果是:
C:\WINNT\test.txt
C:\Winnt\test.txt
C:\Winnt\test.txt