By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,468 Members | 1,865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,468 IT Pros & Developers. It's quick & easy.

objectinputstream and fileinputstream

P: n/a
Hello,
I am getting a problem with objectinputstream and fileinputstream.
Whenever I try to close a ObjectInputStream object it gives an
Exception. And if I try to delete the associated file on disk, the
file doesnt get deleted.

The code I have used is of following manner.

File tempfile=new File("somefile");
FileInputStream fis=new FileInputstream(tempfile);
ObjectInputStream ois=new ObjectInputStream(fis);
Now if I do

try { ois.close();
fis.close
}
catch(Exception e ) {..} // control enters catch block
try {
tempfile.delete();
}
catch(Exception e ) {..}

The File does not get deleted.
Could you please help me in this matter.

regards,
Abhijit.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SPG
I think that closing the objectinputstream in turn closes its source stream,
hence the call to fis.close() fails as the stream is already closed.

As for the file deletion problem.. Does the file.delete() method return
false? if so I would assume the app does not have enough permissions to
delete that file.

Steve
"Abhijit Gadekar" <ab************@yahoo.com> wrote in message
news:da**************************@posting.google.c om...
Hello,
I am getting a problem with objectinputstream and fileinputstream.
Whenever I try to close a ObjectInputStream object it gives an
Exception. And if I try to delete the associated file on disk, the
file doesnt get deleted.

The code I have used is of following manner.

File tempfile=new File("somefile");
FileInputStream fis=new FileInputstream(tempfile);
ObjectInputStream ois=new ObjectInputStream(fis);
Now if I do

try { ois.close();
fis.close
}
catch(Exception e ) {..} // control enters catch block
try {
tempfile.delete();
}
catch(Exception e ) {..}

The File does not get deleted.
Could you please help me in this matter.

regards,
Abhijit.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.