Create File in Java

import java.io.File;
import java.io.IOException;
public class CreateFile {
public static void main(String[] args) throws IOException{
File f;
f=new File("TestReportGenerator.java");
if(!f.exists()){
f.createNewFile();
System.out.println("New file \"TestReportGenerator.java\" has been created to the current directory");
}
}
}

Post a Comment

Previous Post Next Post