belongs to collection: Java File Handling Programs
// Java program to create new file import java.io.File; public class CreateFile { public static void main(String args[]) { final String fileName = "file1.txt"; try { File objFile = new File(fileName); if (objFile.createNewFile()) { System.out.println("File created successfully."); } else { System.out.println("File creation failed!!!"); } } catch (Exception Ex) { System.out.println("Exception : " + Ex.toString()); } } }
Output:
File created successfully.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Create New File using Java Program
Output: