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.

619 questions
8
votes
3 answers

Upgrading a Java Serializable class

I have read various blogs about Serialization and the use of serialVersionUID. Most of them mention using it to maintain the state of a serializable class. The scenario I have is; I know the old serialVersionUID and the new serialVersionUID. On…
Mr R
  • 289
  • 1
  • 6
  • 14
8
votes
2 answers

java.net.SocketTimeoutException: Read timed out

I have an application with client server architecture. The client use Java Web Start with Java Swing / AWT and the sert uses HTTP server / Servlet with Tomcat. The communication is made from the serialization of objects, create a ObjectOutput…
Rafael Soto
  • 165
  • 1
  • 2
  • 8
7
votes
2 answers

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,738
  • 2
  • 24
  • 34
7
votes
4 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
  • 914
  • 2
  • 12
  • 25
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
  • 12,618
  • 23
  • 92
  • 161
6
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…
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
  • 446
  • 2
  • 7
  • 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,788
  • 8
  • 48
  • 82
6
votes
2 answers

When would one use ObjectInputStream.readUnshared() vs .readObject()?

There are two similar methods in the Java ObjectInputStream: readUnshared() and readObject() The documentation states: public Object readUnshared() throws IOException, ClassNotFoundException Reads an "unshared" object from the ObjectInputStream.…
E.S.
  • 2,733
  • 6
  • 36
  • 71
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
  • 647
  • 1
  • 9
  • 15
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

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,943
  • 14
  • 73
  • 115
5
votes
3 answers

Android/Java: How to track progress of InputStream

I have the following code in my Android app, and not sure whether it is my Googling skills, but am not able to find a good tutorial on how to monitor progress of InputStream. private void restoreFromUri(Uri uri) { try { InputStream is =…
Shahid Thaika
  • 2,133
  • 5
  • 23
  • 59
4
votes
6 answers

Java Socket Programming

I am building a simple client/server application using java sockets and experimenting with the ObjectOutputStream etc. I have been following the tutorial at this url http://java.sun.com/developer/technicalArticles/ALT/sockets starting half way down…
Malachi
  • 33,142
  • 18
  • 63
  • 96
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
  • 188,624
  • 52
  • 326
  • 405
1
2
3
41 42