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