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
2 answers

How to save HashMap to file?

Sorry for my poor English. I have a HashMap to save some InstanceStates of a RecyclerView,and I want to save the HashMap into a file. I use the ObjectOutputStream,it can write into a file,but when I use…
DawnYu
  • 2,278
  • 1
  • 12
  • 14
2
votes
1 answer

Sending Multiple Files Via Socket using ObjectOutputStream

I'm creating an application which I have to send multiple images one after another and I use Object(Output/Input)Stream inside of a while loop. But It only send one file I guess its the first image. Can I send multiple files with…
2
votes
1 answer

Java object serialization, how to use same file after using it with ObjectOutPutStream

I want to serialize a simple class Person (with name and age) into a file called "somepersons.ser". Basically I want to achieve the behaviour of the following code: Person p1 = new Person("Person1", 45); Person p2 = new…
2
votes
3 answers

Sending Executable Java over a Socket

I'm working on a networking project in Java where I want to send some executable code from Node A to Node B and have Node B return the result of the executed code back to Node A. The way I went about trying to do this (Which I now know isn't…
mickzer
  • 5,958
  • 5
  • 34
  • 57
2
votes
2 answers

Serializable ObjecOutputStream object

I want to make server client aplication and use ObjecOutputStream to send Object to client, but in object which I want to send is ObjectOutputStream object and I need to serializable it somehow but I dont know how... any advice? I need to send…
user3412372
  • 185
  • 1
  • 1
  • 6
2
votes
1 answer

EOFexception in Java when reading objectinputstream

I want to read multiple objects (my own class Term) that I have output to a .dat file, but I always get a nullPointException or EOFException. ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(masterFile)); Object o =…
user276712
  • 862
  • 4
  • 12
  • 20
2
votes
1 answer

Should I call reset() before close() on an ObjectOutputSream?

I'm taking over an existing JAVA project which containing the following code: class ConnectionHandler extends Thread { private Socket socket; public ConnectionHandler(Socket s) { this.socket = s; } private void…
KF Lin
  • 1,273
  • 2
  • 15
  • 18
2
votes
2 answers

Why is my ObjectInputStream throwing an EOFException?

I am writing a chat room code and each message is sent back and forth between client and server constantly. I have made all the messages into serialized objects and am using them to pass the information back and forth. Unfortunately this has led to…
2
votes
0 answers

ObjectInputStream Android

I have some trouble with the ObjectInputStream in an little android project. On my Laptop I have a Server running, which respondes an int to a String, which comes from my client (running on my andoid device). Here is my Server: ServerSocket…
2
votes
0 answers

Using resources of try-with-resources outside try

I'm using SocketChannel to send message between a server and a client. Once a client connects with a server, the server opens the InputStreams and OutputStream in a try-with-resources try, to receive messages from the client and send messages to the…
2
votes
2 answers

Java serializable security over TCP

I have a TCP/IP chat application that sends back and forth ChatMessage objects that hold the int type and String message of a message. My question is: How can I make it more secure? Thank you!
2
votes
4 answers

If I close ObjectOuputStream, then do not need to close FileOutputStream?

My code like below. Map aMap = new HashMap(); aMap.put("A", "a"); FileOutputStream fos = new FileOutputStream(new File("some.txt")); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.write(aMap); oos.flush(); oos.close(); I…
Juneyoung Oh
  • 7,318
  • 16
  • 73
  • 121
2
votes
1 answer

Reusing ObjectOutputStreams in Java

I am reusing ObjectOutputStream to send updates between the two clients, this is the server code, public void run() { try { toPlayer1.writeBoolean(true); toPlayer1.flush(); while (true) { try { …
2
votes
1 answer

ObjectInputStream read a empty object

I wrote a object using ObjectOutputStream, and read it using ObjectInputStream, and tested it , I get the expected result. But when write the object in other machine, read it in my computer, the read object's members are empty. Could someone help…
cstur4
  • 966
  • 2
  • 8
  • 21
2
votes
2 answers

JAVA writing and loading an Object ArrayList

I'm working on a program about students (saving the name, age and other information into objects and storing those objects into an arrayList). So far so good, I even got the JFrames to work exactly how I want them but the problem shows up when I try…