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

Error with serializable class

I have a java server that sends some data through a socket to a client developed in android. The data that sent is serialized...and at the client side when trying to read from the ObjectInputStream I get the following error: …
embry
  • 309
  • 6
  • 18
2
votes
0 answers

How to save the object which has ArrayList of other objects using DataOutputStream?

How to save the object which has ArrayList of other objects using DataOutputStream and then load them from the file? I'm using serialization, but ArrayList's objects don't want to load. Here I save: void saveChunk(Chunk chunk) { String…
2
votes
2 answers

return an object using ObjectOutputStream

I found a segment of java code that is claimed to return object using ObjectOutputStream OutputStream outstr = response.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(outstr); oos.writeObject(process); …
bit-question
  • 3,733
  • 17
  • 50
  • 63
2
votes
1 answer

Simple P2P server, object gets corrupted after being relayed from the server

Using public class Server { private static ServerSocket server; private static int port = 9876; private static Socket p1 = null; private static Socket p2 = null; public static void main(String args[]) { …
2
votes
2 answers

I'm having troubles with Java sockets in a client/server type application when having to accept many connections

First of all, thanks for reading. This is my first time in stackoverflow as user, although I've always read it and found useful solutions :D. By the way, sorry if I'm not clear enough explaining myself, I know that my English isn't very good. My…
2
votes
1 answer

The program stops when the ObjectInputStream object is created

I have two methods in server and in client: Server: @Override public void start(Stage primaryStage) throws Exception { socket = new Socket("localhost", 9998); System.out.println("connected"); input = new…
user10847573
2
votes
2 answers

Java - How to make ObjectInputStream read all objects from file

import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import…
2
votes
2 answers

ObjectOutputStream in try-with-resources

I am using ObjectOutputStream to write the data into a file. Following is the code snippet. try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f))) { oos.writeObject(allObjects); } Questions: Do I need to split the…
Vikron
  • 25
  • 1
  • 6
2
votes
1 answer

ObjectInputStream block my socket

I want to make use of ObjectInputStream and ObjectOutputStream to send data over Socket. I looked on the internet, but even with several explanation, i'm unable to fix my problem. Here is my contructor succession: public class Server { //Entry…
2
votes
1 answer

Java serialize and immediately deserialize gives error

Object before = ""; ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oo = new ObjectOutputStream(os); oo.writeObject(before); oo.close(); String serialized = os.toString("UTF-8"); …
2
votes
2 answers

Correct way to close the ObjectInputStream and ObjectOutputStream

I am trying to make a class in which I can serialize and deserialize an object. The class should work in this way: I serialize the object and send it to server and then the server will modify one field of my object and send it back so I can…
2
votes
1 answer

'java.io.ObjectOutputStream' is deprecated - an error in Intellij IDEA

I have this code: import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Date; public class EmployeeProcessor { public static void main(String[] args) { Employee employee = new…
Vitali Plagov
  • 722
  • 1
  • 12
  • 31
2
votes
1 answer

Why an object doesn't change when I send it through writeObject method?

I'm making networking program with Java. As the title, the object which server is trying to send is changed in client which receives it. I'm trying to change the object which exists in client before I receive the new one from server. Here's my…
JHKwag
  • 31
  • 4
2
votes
1 answer

Write ObjectOutputStream append file, keep getting StreamCorruptedException error

I want to write an Object file with append. I have a class NewContact and main class below: private String name; private String sex; private String mail; private String phone; private String image; //setter and getter method.…
Quan Nguyen
  • 90
  • 2
  • 10
2
votes
2 answers

How to serialize an object containing an Image?

How i can sent object with Image? I am getting this error: java.io.NotSerializableException: org.eclipse.swt.graphics.Image I can sent normal object, e. String, or whatever other objects. public void sentObject(Card GraczK) throws IOException…
Pekus
  • 155
  • 1
  • 6
  • 12