Questions tagged [objectoutputstream]

The Java ObjectOutputStream serialization class from the Java standard library.

ObjectOutputStream is a class from the Java standard library that can be used to serialize and write objects previously that can later be read and deserialized by an ObjectInputStream instance.

566 questions
3
votes
2 answers

Deserialization using Externalizable interface in Java

I'm learning about Serializable and Externalizable interface and I see that, when an Externalizable object is reconstructed, an instance is created first using the public no-arg constructor, then the readExternal method is called. If the object does…
3
votes
1 answer

Blank String added in a Integer array when sending from a java socket

I am trying to send an integer array using ObjectOutputStream and WriteObject method from a client and receiving the array from the server. Here is Client and Server code respectively: Client: int numberArray [] = new…
3
votes
0 answers

object output stream not working with mulithreading

I'm creating a chat for a game that runs on a server and client system, and then of course the game on the server client system, but I cannot get my multithreaded program to work, and I'll explain how below. What I can say is the server client…
3
votes
1 answer

Send object over socket

I'm trying to send a custome object through socket in java. I know that i need to put class that has object i need to send in same package, have the same serialVersionUID and implement Serializable. I have already did it but i still can't send…
user964843
3
votes
2 answers

ObjectOutputStream - Object exceeding 1GB causes java.lang.OutOfMemoryError: Requested array size exceeds VM limit

I am trying to write file a Collection (ArrayList) of third party Externalizable class instances (Drools KnowledgePackage) using ObjectOutputStream in Java 7. If I limit the KnowledgePackage sizes so the resulting file is <= 1GB all is well. If I…
David B
  • 93
  • 6
3
votes
1 answer

How to read different Object using ObjectInputStream in Java

Note: it's not a duplicate, because here we want to write not only Objects, but also a whole file, then read it back. I have created a single File with 3 Objects using ObjectOutputStream, String String File ( size is between [1 to 1.5]GB ) Below…
3
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
  • 371
  • 1
  • 9
  • 19
3
votes
2 answers

Storing Byte Array inside an Object, and then converting it to ObjectOutputStream? (Stuck)

I'm kind of stuck with this problem. I have this FileDetails class which stores details/metadata of the file along with the complete file in a byte array. I want to send the FileDetails object inside ObjectOutputStream across network, where the…
Retr0spect
  • 187
  • 1
  • 13
3
votes
2 answers

FileNotFoundException (Access is denied) when trying to write to a new file

My goal I am trying to write simple objects (SimpleType) into files, so that the files can be loaded later and the objects recreated. My setting I am currently working in the NetBeans IDE (JDK8) on a Windows 7 machine. I don't think that should make…
MaxAxeHax
  • 423
  • 7
  • 14
3
votes
1 answer

Changing instance state does not get reflected in serialized object

I wrote following simple code public static void main(String args[]) throws FileNotFoundException, IOException, ClassNotFoundException { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("data.txt"))); Human human…
3
votes
2 answers

java.io.EOFException while writing and reading froma servlet

I have the following code on the applet side: URL servlet = new URL(appletCodeBase, "FormsServlet?form=requestRoom"); URLConnection con =…
mithun1538
  • 1,447
  • 8
  • 25
  • 32
3
votes
1 answer

Object property change is not saved after streaming in java

Update: OK so I've grayed out parts of code and found what was causing the problem. I've added here 3 lines of code with the comment "this is the added code that causes the problem". But I still don't understand why it affects the result. I am…
Elyakim Levi
  • 360
  • 4
  • 16
3
votes
1 answer

Remove the header of ObjectOutputStream

how to remove the Header added by objectOutputStream? what way should be the writeStreamHeader be Overriden..? @Override protected void writeStreamHeader() throws IOException { } It want the byteOutputStream (to which i m writing the object)…
Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33
3
votes
3 answers

outputStream shutdown causes the other Streams blocks?

I have a server with many clients.. Every connection arrives to the server if it's accepted, I send it to a thread: server= serverSocketcht.accept(); new ThrdConv(server).start(); in the ThrdConv thread I set the input stream and output stream to…
EsmaeelQash
  • 488
  • 2
  • 6
  • 20
3
votes
1 answer

Must server & client have reverse sequence of claiming ObjectOutputStream & ObjectInputStream?

In my experiment, if Server has this: ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream()); ObjectOutputStream objectOutputStream = new ObjectOutputStream(socket.getOutputStream()); then client side has to do this,…