Reply to comment

Creating Text File in Java

Tagged:  
import java.io.File;
import java.io.IOException;

public class CreateFile {

	public static void main(String[] args) {

		String path = "/home/jr/Desktop/file01.txt";
		File file = new File(path);

		if ( file.exists() )
			System.out.println("file already exist");
		
		else
			try {
				file.createNewFile();
			} catch (IOException e) {				
				e.printStackTrace();
			}
	}
}

Reply

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.