Create new file with java.nio.file.Files in Java
Description
The following code shows how to create new file with java.nio.file.Files.
Example
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
//from www.java2 s . co m
public class Main {
public static void main(String[] args) throws Exception {
Path newFile = FileSystems.getDefault().getPath("C:\\home\\docs\\users.txt");
Files.createFile(newFile);
System.out.println("File created successfully!");
}
}