developerfranso / find-ur-pal

Automatically exported from code.google.com/p/find-ur-pal
0 stars 0 forks source link

Ans to issue4 #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
public void fileDelete(String fileName)
{
File f = new File(fileName);

   // Make sure the file or directory exists and isn't write protected
   if (!f.exists())
     throw new IllegalArgumentException(
         "Delete: no such file or directory: " + fileName);

   if (!f.canWrite())
     throw new IllegalArgumentException("Delete: write protected: "
         + fileName);

   // If it is a directory, make sure it is empty
   if (f.isDirectory()) {
     String[] files = f.list();
     if (files.length > 0)
       throw new IllegalArgumentException(
           "Delete: directory not empty: " + fileName);
   }

   // Attempt to delete it
   boolean success = f.delete();
   //System.out.println(success);
   if (!success)
     throw new IllegalArgumentException("Delete: deletion failed");
}

Original issue reported on code.google.com by mannika0...@iiitd.ac.in on 28 Oct 2011 at 4:57

GoogleCodeExporter commented 9 years ago
Oh thanks! This works! :)

Original comment by saloni09...@iiitd.ac.in on 28 Oct 2011 at 4:59