Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JAVA I/O Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JAVA I/O" Watch "JAVA I/O" New topic
Author

JAVA I/O

Jerret Halter
Ranch Hand

Joined: Feb 03, 2006
Posts: 62
I am trying to work with deleting files and directories in Java 5 but have been unsuccessful. With the following code below a file and directory is created but I cannot delete them. Is there something I am doing wrong?



Jerret Halter<br /> <br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.<hr></blockquote>
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Remember that Windows locks files when they are open. Because you don't close the BufferedReader before you try to delete the file, it won't delete. Close the BufferedReader first, and it will delete.
Jerret Halter
Ranch Hand

Joined: Feb 03, 2006
Posts: 62
Fantastic :-) Thank you for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAVA I/O
 
Similar Threads
To find a largest sector in a given input string of 1's and 0's
working with files and directories
Reading a file from a directory.
Creating my First Object
check values in a csv file in all files in a directory