Program to demonstrate how to create a file in Java.
Click here to download complete source code
Click here to download complete source code
Click here to download complete source code
import java.io.File; import java.io.IOException; public class CreateFile { public static void main(String[] args) { File file = new File("test.txt"); try { if(file.createNewFile()) { System.out.println("File successfully created."); } else { System.out.println("File already exists."); } } catch(IOException ioe) { System.out.println("IO Exception occured."); } } }
Click here to download complete source code