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
-1
votes
1 answer

How to preserve line breaks when writing ArrayList to file with ObjectOutputStream?

I'm following this tutorial on how to output an ArrayList to a text file with ObjectOutputStream, but this removes the line breaks from my original file. In other words, I read a file in, do stuff to it, and write it back out. The data read in…
user8121557
  • 149
  • 2
  • 9
-1
votes
1 answer

SocketException: Connection reset when serializing

I have a basic TCP connection where i send an object from client to server through serialization. But i'm getting an error when performing this simple task, below is the code: Client: public client() throws IOException{ Socket socket = new…
-1
votes
1 answer

My class is Serializable and i have java.io.NotSerializableException why?

I have this exception and I don't understand why. The error log : java.io.NotSerializableException: java.io.ObjectOutputStream at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) at…
-1
votes
1 answer

Does writeObject(Object obj) write the whole class of the object?

Regarding the method writeObject(Object obj) from ObjectOutputStream class From Javadocs: Write the specified object to the ObjectOutputStream. The class of the object, the signature of the class, and the values of the non-transient and…
-1
votes
1 answer

Editing serialized object

I have a serialized object stored in a file (with ObjectOutputStream). Is it possible to edit the serialized object in the file without deserializing and re-writing the file?
-1
votes
1 answer

Java throws InvalidClassException while reading the stream

I want to read from a file using FileInputStream and ObjectInputStream. I have created BankAccount class which implements Externalizable interface and @overriden both its methods. I do not understand why it throws an IOException. These are the…
-1
votes
1 answer

Writing object into ObjectOutputStream doesn't work

i'm writing (testing) a simple client-server application where i need to send some object via socket's ObjectOutputStream and next read it via socket't ObjectInputStream. The problem is that the ObjectOutputStream writeObject method doesn't work…
Robert
  • 46
  • 8
-1
votes
1 answer

Why does ObjectInput/OutputStream lose object references when reading and writing to file?

I have two classes that interact: Shelf, that stores CDs, DVDs, PaperMedias: public class Shelf { private ArrayList cds; private ArrayList dvds; private ArrayList paperMedias; ...etc And…
-1
votes
1 answer

how to update class by socket

// CLIENT SOURCE while(!isStop){ try{ Object ob = mc.getOis().readObject(); try{ message = (String) ob; } catch (ClassCastException e){ try { user = (User) ob; …
-1
votes
1 answer

ObjectOutputStream duplicate output

Cannot even find the problem itself in this case. When the program reads from objects.dat, the output is only the variables of the last objects in the array. Program output screenshot. I have combed through the code several times and cannot find the…
Kacey VH
  • 3
  • 3
-1
votes
1 answer

Failed to deserialize sealed objects from Cipher input stream

Why do I get an invalid stream header error when I read an object from a CipherInputStream ? (edit: possibly due to re-use of Cipher object?, new version of sample code included below has resolved the issue.) My program is trying to read from an…
-1
votes
1 answer

How do I take an array of objects and update the object data file after changing variables in the array?

I have an array of objects and I am trying to change the values of the objects and then re-update the storage file where the object-in-file are stored. When I try changing the storage file it either clears the file or does nothing. Here is my…
Bear
  • 1
-1
votes
1 answer

Read And Write Obj in Java From File . EOFException

I'm trying to write an object on a file, and then to read it from the same file i populated an arraylist of object from a simple text file. i have an EOFException when i'm trying to write on file public class CaricaTestoScriviOggetti_Copia { …
-1
votes
1 answer

ObjectOutputstream overwriting old object without closing stream

What I want to achieve: When I save an Integer object to a file using the writeObject() method from ObjectOutputstream class, I want to overwrite the old Integer object and replace it with the new one. But I don't want to close and open again the…
Le No
  • 3
  • 1
  • 2
-1
votes
1 answer

Java serializing object with ObjectOutputStream works once , tried reset() on both sides

I am using this static class as a way to serialize objects into strings before sending / using them in various ways. However the objects being serialized only seem to be serialized correctly once. A variable that starts at 20 and increments every…
r3eckon
  • 14
  • 3