Tuesday, 4 August 2015

Create file and overwrite if it exists Using Java

The following code 'll delete the file 'myfile.html' if exists and 'll create a new file 'myfile.html'

    File f = new File("myfile.html");
    if(f.exists()){
        f.delete();
        f.createNewFile();
    }

No comments:

Post a Comment