473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

objectinputstream and fileinputstream

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
1 3625
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Offer | last post by:
Hi, I create a TCP connection between client & server and I need to send vectors via ObjectInputStreams back and forth (the client initiates the protocol). The connection is established...
1
by: David Liebtag | last post by:
I have what I hope is a simple question: I'm learning how to serialize objects. I create an ObjectOutputStream and writeObject an object to it. I then create an ObjectInputStream and try to...
3
by: Jacqueline Snook | last post by:
I am trying to reference a file on an apple mac from Java. In order to find what the URL is supposed to be, I opened it in the Safari web browser. The directory as returned was...
6
by: Patrick | last post by:
Hello all! I am porting an application from C++ to Java and have run into a problem using the DataInputStream reader object. The file I am trying to read in is anywhere from 20 to 60 MB and has a...
2
by: Krzysztof Paz | last post by:
Hi, There is a Java (SUN 1.4) server which using Object Input/Output Streams at SSL/Socket to communicate with Java clients. Now there is a request for making C# Client for this server also. SSL...
6
Nepomuk
by: Nepomuk | last post by:
Hi! I'm trying to transfer files and to do so must, of course, read them. Now, my reference File has a size of 4.240.821 Bytes and I need something between 9 and 14 seconds to simply read it and...
6
by: Tukeind | last post by:
Hello, I've opened a file (code below) containing file names onto a FileInputStream, and attempting to open each file and place its contents onto a FileOutputStream (or buffer) and need help getting...
3
by: blackraven1425 | last post by:
The ObjectInputStream in this code is giving a EOFException. Do I need to do anything special to get this to work withou the EOF exception? It gives the exception at the line of the first instance of...
10
by: Humakt | last post by:
I'm trying to figure a good way to handle saving game state to file (common save/load game function in games). ObjectOutput/InputStream seems most promising so far. However,the object I'm saving...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.