1

I have created Hidden folder in windows from this link..Now i have to delete one file in that hidden folder.

eg.C:\program files\test\abc.xml

I want to delete abc.xml and i have used following code for delete in java

String path="C:\program files\test\abc.xml"
 if(new File(path).exists()){
  new File(path).delete()
 }

The attribute set as N for this file instead of deleting. I do not know what happening?

Note: abc.xml file is encrypted file.

Can any one help me.

Thanks.

Community
  • 1
  • 1
Ami
  • 4,241
  • 6
  • 41
  • 75

2 Answers2

2
String path="C:\\program files\\test\\abc.xml"

Try escaping your backslashes and see if that works.

Grambot
  • 4,370
  • 5
  • 28
  • 43
  • Thanks.but its not working.File is not deleted.i have edited the question. – Ami Jan 23 '13 at 11:34
  • I would suggest re-writing your delete code to test the delete function and report any exceptions it may encounter: http://www.mkyong.com/java/how-to-delete-file-in-java/ if that doesn't work report back with more details like errors. Perhaps its a permissions problem? – Grambot Jan 23 '13 at 15:06
0
FileUtils.cleanDirectory(new File("C:\\\program files\\\test\\\"));

It will take care of everything in the directory.

Just need to add Apache Commons IO jar to your path.

Ashish Kakkad
  • 23,586
  • 12
  • 103
  • 136