473,396 Members | 1,907 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,396 software developers and data experts.

problems with ObjectInputStream

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 ObjectInputStream.

public static ArrayListSerial getList() {
try {
try{
try {
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("J:\\collectibles.dat")));
Object inObject;
inObject = in.readObject();
if(inObject instanceof ArrayListSerial){
ArrayListSerial inObject2 = (ArrayListSerial)inObject;
return inObject2;
}
}catch(EOFException z){
System.out.println("Not");
z.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
ArrayListSerial collectibles = new ArrayListSerial(100);
item item = new item();
item.changeName("test");
collectibles.add(item);
saveList(collectibles);
e.printStackTrace();
return collectibles;

}
return null;
}
Mar 31 '08 #1
3 1871
Oh,and this is after it makes the array for the first time too. The file exists, but there's no data in it.
Mar 31 '08 #2
JosAH
11,448 Expert 8TB
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 ObjectInputStream.
I bet you didn't flush/close the ObjectOutputStream properly when you wrote
the object to a file.

kind regards,

Jos
Mar 31 '08 #3
That was absolutely it. Thanks a lot for the help!
Mar 31 '08 #4

Sign in to post your reply or Sign up for a free account.

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...
1
by: Abhijit Gadekar | last post by:
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...
14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
5
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
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...
8
by: marknvicf | last post by:
I have read a bit about the endian differences, got a couple of jar/libs to help (Android and com.mindprod), but still am not sure how to fix this program that I have (written in JDK 1.4 by someone...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.