Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Open File, Close, Delete -- Will Not Delete
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

Report this thread to moderator Post Follow-up to this message
Old Post
Hal Vaughan
12-01-04 01:59 AM


Re: Open File, Close, Delete -- Will Not Delete
I 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



Report this thread to moderator Post Follow-up to this message
Old Post
Jacques Desmazieres
12-01-04 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 01:22 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.