Skip to content

Instantly share code, notes, and snippets.

@fernandobgi
Created July 11, 2012 13:27
package br.com.ocjp.io;
import java.io.File;
import java.io.IOException;
public class ClassFile {
public static void main(String[] args) {
File f = new File("C:\\temp\\file.txt"); // There is no file yet.
System.out.println("Does the file exist? " + f.exists());
try {
boolean flag = f.createNewFile(); // May Create a real file
System.out.println("File has been created " + flag);
System.out.println("Does the file exist? " + f.exists());
} catch (IOException e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment