February 27, 2013

Delete File in java

How to delete a file in java



package blackberry;

import java.io.*;
 
public class DeleteFile

{
 
private static void deletefile(String file)
{
 
File f1 = new File(file);

boolean success = f1.delete();

if (!success)
{
 
System.out.println("Deletion failed.");

System.exit(0);
}

else
{
System.out.println("File deleted Successfully.");
}

}
 
public static void main(String[] ran)

{
 
    switch(args.length)
{
 
case 0: System.out.println("File has not mentioned.");
 
          System.exit(0);
 
case 1: deletefile(ran[0]);

         System.exit(0);
 
default : System.out.println("Multiple files are not allow.");
 
            System.exit(0);
  
 }
 
}

}

.ini file


Gutmann algorithm for secure file deletion read here

java blog

Facebook comments