HOME      BLOG       FORUMS      CONTACT       ABOUT

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);
	}
}

Share

Tags: , , , , ,


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.

AddThis Social Bookmark Button

Leave a Reply