How to create a new file in Java

2

There are various ways in which you can create a new file in Java. In this article, I’ve outlined the two most recommended way of creating new files. Create New file using Java NIO (Recommended) - JDK 7+ You can use Files.createFile(path) method to create a new File in Java: import java.io.IOException; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class CreateNewFile { public static void main(...

Read this post on callicoder.com


Rajeev Kumar Singh

blogs from Bangalore