Following code is to create file "testfile.txt" in current directory.
import java.io.*;
public class SampleFile{
public static void main(String[] args) throws IOException{
File f=new File("testfile.txt");
if(!f.exists()){
f.createNewFile();
System.out.println("New file \"myfile.txt\" has been created
to the current directory");
}
}
}
No comments:
Post a Comment