Creating new file
Creating new file
The createNewFile method of file class can be used for creating a new file. The createNewFile method returns true if the file does not exist and was successfully created an empty file.
package io;
import java.io.File;
import java.io.IOException;
public class FileExample {
public static void main(String[] args) throws IOException{
File file = new File("d:\\temp\\test1.txt");
// Create new file.
boolean isCreated = file.createNewFile();
System.out.println(isCreated);
}
}
Tags: create new file, File, file class examples, File examples, java.io, java.io.File
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply