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
62
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
  • 49,047
  • 44
  • 147
  • 241
45
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
  • 371
  • 1
  • 3
  • 7
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
  • 799
  • 2
  • 14
  • 23
26
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
  • 26,935
  • 59
  • 154
  • 188
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,920
  • 4
  • 29
  • 43
16
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…
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,103
  • 1
  • 17
  • 27
13
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
  • 38,729
  • 14
  • 126
  • 182
11
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
  • 438
  • 1
  • 6
  • 16
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
  • 8,261
  • 23
  • 83
  • 124
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
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
  • 161
  • 1
  • 2
  • 9
8
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
  • 81
  • 1
  • 3
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,673
  • 4
  • 19
  • 25
1
2 3
41 42