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