This discussion is archived
7 Replies Latest reply: Dec 22, 2011 1:53 PM by EJP RSS

Delete a file using Java

902241 Newbie
Currently Being Moderated
Hi,


I have no success with my code:
File excluido = new File("teste.txt");
excluido.setWritable(true, true);
SecurityManager sm = new SecurityManager();
try {
     sm.checkDelete(excluido.getAbsolutePath());
               
        excluido.delete();                    
               
} catch (SecurityException se) {
se.printStackTrace();
} 
   
it throws SecurityException all the time, both on Windows and Linux.

The file teste.txt is always found, by the way.

Thank you in advance for any input.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points