Questions tagged [objectinputstream]

The Java `ObjectInputStream` deserialization class from the Java standard library.

ObjectInputStream is a class from the Java standard library that can be used to read and deserialize objects previously serialized by an ObjectOutputStream instance.

589 questions
7
votes
1 answer

what causes : java.net.SocketException: Connection timed out, Not the SocketTimeoutException

This SocketException is thrown in ObjectInputStream.readObject() method, what cause this excetpion? Besides, the values of soTimeout of client and server socket are both 0, and KeepAlive value is false. {2012-01-09 17:44:13,908} ERROR…
Shawn Lee
  • 151
  • 1
  • 2
  • 9
7
votes
1 answer

Java - Listening to a socket with ObjectInputStream

Ok so , i have a thread class called 'Client' every time the server accepts a connection it creates a new Client....The run method listens for messages from the client and i am useing ObjectInputStream .. do { …
Mustafa
  • 1,551
  • 1
  • 18
  • 31
7
votes
3 answers

(java) ObjectInputStream deserializing wrong version of object

I'm just learning networking from a java book, so I'm a bit of a noob. I couldn't find this problem in the book or online so I decided to ask the internet. The book says to use the ObjectOutputStream and ObjectInputStream to send and receive objects…
superzipzop
  • 71
  • 1
  • 3
7
votes
5 answers

ObjectOutputStream methods: writeBytes(String str) vs writeUTF(String s);

What's the main difference between the two? Still both of them are for writing Strings. public void writeUTF(String str) throws IOException Primitive data write of this String in modified UTF-8 format. vs public void…
Rollerball
  • 11,004
  • 22
  • 81
  • 136
6
votes
2 answers

Java ObjectInputStream hanging

I am feeling really stupid right now guys.... basically I am connecting over TCP on a local machine... and when I try to make the In/out streams at the client it wont get passed creating the object input stream. What gives? This stops after printing…
Michael
  • 436
  • 2
  • 6
  • 19
6
votes
1 answer

Java serialization: readFields() beyond of readObject()?

ObjectInputStream.readFields() is eligible only within private void readObject(ObjectInputStream) method. public ObjectInputStream.GetField readFields() throws IOException, ClassNotFoundException { SerialCallbackContext ctx = curContext; if…
FoxyBOA
  • 5,688
  • 6
  • 43
  • 72
6
votes
2 answers

ObjectInputStream from file causing memory leaks

I have a huge file with a list of objects written by ObjectOutputStream, one after another. for (Object obj : currentList){ oos.writeUnshared(obj); } Now I want to read this file using ObjectInputStream. However, I need to read multiple files…
copperhead
  • 547
  • 1
  • 7
  • 14
5
votes
3 answers

ObjectInputStream Error

I am using ObjectOutputStream to create a file of serialized objects. I then use an ObjectInputStream to with the readObject() method to get the objects back out of the file. It works great the first time. Meaning that if the file does not exist…
JavaDunce
5
votes
1 answer

Send an Anonymous class over sockets? (Object..Stream in Java)

So right now, I have a server that is running with ObjectInputStream and ObjectOutputStream. The problem I am having is that I have a custom (anonymous) class that extends java.lang.Date that I am trying to send to the client and then compile. So…
5
votes
1 answer

ObjectInputStream - How to wait for new data?

I've got a client-server app I'm making and I'm having a bit of trouble when reading objects on the server. After my server connects to a client socket, I build object input and output streams and pass them along to my service() method. In there,…
jbrennan
  • 11,523
  • 14
  • 69
  • 110
5
votes
3 answers

Exception.getCause() returning null when trying to find the source of an exception

why does System.out.println(e.getCause()); gives null? And can store whole HashSet collection like this? private void saving() throws IOException, ClassNotFoundException { ObjectOutputStream out = null; try { out = new…
nkvnkv
  • 871
  • 2
  • 11
  • 23
4
votes
3 answers

program hangs on ObjectInputStream readObject method .

I want to share object of type Stuff which contains ( String name,address,title, ... and byte[] picture ) when connection is established after that my code hangs on objectinputstream readObject() function . No streaming occurs. Can anyone please…
Ahmed
  • 786
  • 2
  • 16
  • 37
4
votes
1 answer

ObjectInputStream read Array

I am trying to read in an array from ObjectInputStream in Java. I can find no documentation on how to do this. I assume that it is readObject(), but this doesn't seem to work. out.write(Object) out.write(Object) out.write(boolean[]) ... in…
Explosion Pills
  • 176,581
  • 46
  • 285
  • 363
4
votes
5 answers

How to store and read an array list of objects in java?

I am having difficulties w/ writing and reading an array of objects from a file. This is how my object looks like: package registar; import java.io.Serializable; public class Vozilo implements Serializable { private static final long…
Nikola
  • 351
  • 1
  • 7
  • 17
4
votes
2 answers

Why this strange behaviour of ObjectOutputStream and ObjectInputStream throwing EOFException?

I wrote a custom serializing/de-serializing logic for persisting some of the data as Java default serialization turned out to be both time and memory expensive. For this purpose I wrote readObject(ObjectInput in) and writeObject(ObjectOutput out)…
Setu
  • 1,963
  • 1
  • 16
  • 28
1
2
3
39 40