File(File parent, String child)
建構函式具有以下語法。
public File(File parent, String child)
在下面的程式碼顯示如何使用File(File parent, String child)
建構函式。
import java.io.File;
// By: WW w .Y iI b a i.COM
public class Main {
public static void main(String[] args) {
File parent = new File("c:/aFolder");
File aFile = new File(parent, "aFile.txt");
System.out.println(aFile);//c:\aFolder\aFile.txt
}
}
上面程式碼執行結果如下 -
c:\aFolder\aFile.txt