Java Java File.getCanonicalFile()
方法具有以下语法。
public File getCanonicalFile() throws IOException
示例
在下面的代码显示如何使用File.getCanonicalFile()
方法。
import java.io.File;
// from:w w W .yI I ba i.c o M
public class Main {
public static void main(String[] args) throws Exception {
// create new files
File f = new File("test.txt");
File path = f.getCanonicalFile();
System.out.print("Absolute Pathname " + path);
}
}
上面代码执行结果如下 -
Absolute Pathname F:\website\yiibai\worksp\test.txt