Java Examples – How to create a file in Java

File.createNewFile() Method can be used to Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. File.createNewFile() Method returns true if the named file does not exist and was successfully created; false if the named file already exists.

Below is the example to create a file in java.

Java Examples – Create a File and Write in it Using PrintWriter and File class


Partner Sites