import java.io.*;
public class Ex_File{
public static void main(String args[]){
File f = new File("NewFile.txt");
System.out.println("Data exist: "+ f.exists());
if(!f.exists()){
System.out.print("Use createNewFile() \n");
}
try{
System.out.println(f.createNewFile());
}catch(IOException e){
System.out.println(e);
}
System.out.println("Data exist: "+ f.exists());
}
}
---------------------------------------
Data exist: false
Use createNewFile()
true
Data exist: true
沒有留言:
張貼留言