7 Replies Latest reply: Dec 22, 2011 3:53 PM by EJP RSS

    Delete a file using Java

    902241
      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.