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
61
votes
6 answers

Appending to an ObjectOutputStream

Is it not possible to append to an ObjectOutputStream? I am trying to append to a list of objects. Following snippet is a function that is called whenever a job is finished. FileOutputStream fos = new FileOutputStream …
Hamza Yerlikaya
  • 47,689
  • 37
  • 135
  • 231
42
votes
10 answers

The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

I have downloaded Eclipse and tried to create a sample servlet program but I got following error The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files I have configured build path…
user3891270
  • 341
  • 1
  • 3
  • 6
38
votes
11 answers

Load files bigger than 1M from assets folder

I'm going crazy, I created a file object, so it can be read with ObjectInputStream, and I placed the assets folder. The method works with a file smaller than 1M, and give error with larger files. I read that is a limit of Android platform, but I…
Syco
  • 755
  • 2
  • 13
  • 19
25
votes
9 answers

Java FileInputStream ObjectInputStream reaches end of file EOF

I am trying to read the number of line in a binary file using readObject, but I get IOException EOF. Am I doing this the right way? FileInputStream istream = new FileInputStream(fileName); ObjectInputStream ois = new…
user69514
  • 24,321
  • 56
  • 146
  • 183
24
votes
3 answers

Why can I only read 1024 bytes at a time with ObjectInputStream?

I have written the following code which writes 4000 bytes of 0s to a file test.txt. Then, I read the same file in chunks of 1000 bytes at a time. FileOutputStream output = new FileOutputStream("test.txt"); ObjectOutputStream stream = new…
Zsw
  • 3,312
  • 3
  • 21
  • 41
14
votes
5 answers

ObjectInputStream happy with FileInputStream, not happy with getResourceAsStream

I have some pretty standard code which takes in a serialized object from a stream, which bascially looks like this: Object getObjectFromStream(InputStream is) { ObjectInputStream ois = new ObjectInputStream(is); return ois.readObject(); …
barryred
  • 1,071
  • 1
  • 16
  • 24
14
votes
2 answers

How do I write multiple objects to the serializable file and read them when the program is used again?

I want to maintain database of users of a Bank for my project. I am able to save the number of users in one serializable file. But when I try to save the user to database it adds only the latest one to database. Below is the sneak peak of code which…
12
votes
2 answers

Unexpected OutOfMemoryError when using ObjectInputStream#readUnshared()

I am running into an OOM when reading a large number of objects from an ObjectInputStream with readUnshared. MAT points at its internal handle table as the culprit, as does the OOM stack trace (at end of this post). By all accounts, this shouldn't…
Jason C
  • 34,234
  • 12
  • 103
  • 151
10
votes
5 answers

Performance issue using Javas Object streams with Sockets

I'm trying to do local IPC using Sockets and Object streams in Java however I'm seeing poor performance. I am testing the ping time of sending an object via an ObjectOutputStream to receiving a reply via an ObjectInputStream over a Socket. Here's…
10
votes
4 answers

How can I append to an existing java.io.ObjectStream?

As for now I will get java.io.StreamCorruptedException when I try to append an Object. I have searched the Internet for a way to overcome that. The answer I found so far is it can't be done. A way around this problem is to write the objects into a…
starcorn
  • 7,071
  • 19
  • 73
  • 118
10
votes
2 answers

new ObjectInputStream() blocks

public class SerProg { static ServerSocket ser=null; static Socket cli=null; static ObjectInputStream ins=null; static ObjectOutputStream outs=null; public static void main(String[] args) { try { ser=new…
Abhishek
  • 308
  • 4
  • 15
8
votes
4 answers

StrictMode complains about InputStream not being closed

I'm getting the following violation reported by StrictMode in Android. 02-05 04:07:41.190: ERROR/StrictMode(15093): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource…
8
votes
3 answers

Cannot create ObjectInputStream with InputStream for a Bluetooth Socket on the Android Platform

I am writing a multiplayer game for Android phones. Communication is via Bluetooth. I have managed to send bytes from one phone to the other using the input / output stream. Since I need to be able to transfer objects I want objectstreams. However,…
Alexander
  • 1,493
  • 4
  • 18
  • 24
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
  • 279
  • 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
1
2 3
39 40