Tuesday, November 08, 2011

Create file and overwrite if it exists

The following code 'll delete the file 'myfile.html' if exists and 'll create a new file 'myfile.html'
  1. File f = new File("myfile.html");
  2. if(f.exists()){
  3. f.delete();
  4. f.createNewFile();
  5. }

No comments:

Post a Comment