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


Post new comment