Code Comments
Programming Forum and web based access to our favorite programming groups.When I'm reading or writing to a text file, I use the standard FileInputStream and DataInputStream (of course, I use the output streams for writing). I close the file stream when I'm done with it (as I learned from examples). Whenever I try to delete a file I've recently read from (or written to), I find I can't delete it. I finally write a method in my file admin class that will try to delete a file, check if it was successful, and if not, will do a deleteOnExit(). So am I doing something wrong that I can't delete a recently used file? If so, what? Thanks! Hal
Post Follow-up to this messageI faced a similar problem, I opened files with deleteOnExit and they were not deleted. I solved the problem by closing explicitelly all streams: before I had : dis = new DataInputStream( new FileInputStream( ... .. dis.close() After I had (and it works but I don't know why exactly) : fis=new FileInputStream( dis = new DataInputStream( fis ) ... fis.close() dis.close() Hope this helps Jacques Desmazieres "Hal Vaughan" <hal@thresholddigital.com> a écrit dans le message de news: vvidnazrct-4lzDcRVn-pQ@comcast.com... > When I'm reading or writing to a text file, I use the standard > FileInputStream and DataInputStream (of course, I use the output streams > for writing). I close the file stream when I'm done with it (as I learned > from examples). Whenever I try to delete a file I've recently read from > (or written to), I find I can't delete it. I finally write a method in my > file admin class that will try to delete a file, check if it was > successful, and if not, will do a deleteOnExit(). > > So am I doing something wrong that I can't delete a recently used file? If > so, what? > > Thanks! > > Hal
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.