Java.io.File delete () does not work on Windows 7 (java newbie)

I am new to Java, just trying to make a simple utility to move, copy and delete some wav files on my computer, but java.io.File delete () does not work. The wav files in question have a read-only check (in Windows Explorer), but File canWrite () returns false, and setWritable (true) fails. I must be doing something stupid because someone hasn't had this problem before?

-1
source share
3 answers

You use the relative path, and you are not in the directory that you think.

Specify absolute paths or determine the current path before starting.

0
source

Run the Java application as an administrator. Then try it.

file.setWritable(true); file.delete(); 
0
source

Try running the garbage collector:

 File file = new File("test-file.txt"); System.gc() boolean success = file.delete(); 

http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html

0
source

All Articles