Java Java File.getAbsoluteFile()
方法具有以下语法。
public File getAbsoluteFile()
示例
在下面的代码显示如何使用File.getAbsoluteFile()
方法。
import java.io.File;
// @ W w W.Y iI B A I. C o M
public class Main {
public static void main(String[] args) throws Exception{
// create new files
File f = new File("test.txt");
// create new file in the system
f.createNewFile();
// tests if file exists
boolean bool = f.exists();
System.out.println("File exists: " + bool);
}
}
上面代码执行结果如下 -
File exists: true