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

My executable .jar file won't write a save file

I'm making a game for a school assignment, one of the features is that the game can be saved and loaded. While in eclipse everything worked but after making it an executable jar it won't create the file at the specified location. I am using this…
East
  • 43
  • 1
  • 6
4
votes
3 answers

Java: what file extension should I use when writing objects with ObjectOutputStream

The API shows .tmp, my text book uses .dat and I've seen .ser Does it matter? I'm writing an arraylist of objects
Nicolas
  • 331
  • 4
  • 13
4
votes
1 answer

Java: can´t get ObjectInputStream from socket

I am doing java server client application and I have got problem. I succesfully get client´s socket, bud when I wanna make ObjectInputStream it stuck. Code: serverSocket = new ServerSocket(9999); while(true){ System.out.println("Waiting for…
user3412372
  • 185
  • 1
  • 1
  • 6
4
votes
5 answers

When I run the given code I get A B A as output. I don't understand why it prints A again

Tha code mentioned below returns A B A as output but I didnt understand the logic why A has been printed again after B. class A1 { public A1() { System.out.println("A"); } } class B extends A1 implements Serializable { public…
4
votes
1 answer

Serializing objects with changing class source code

Note: Due to the lack of questions like this on SO, I've decided to put one up myself as a Q&A Serializing objects (using an ObjectOutputStream and an ObjectInputStream) is a method for storing an instance of a Java Object as data that can be…
Parker Hoyes
  • 2,118
  • 1
  • 23
  • 38
4
votes
1 answer

Writing object to internal storage in android (Inside new directory)

I've seen how to write to internal storage using this method.. public void storeSerializedObject(MyObject theObject) { FileOutputStream fileOut = null; String fileName = theObject.getName(); try { fileOut =…
4
votes
3 answers

ObjectInputStream gives me an empty object (but the readed file is not empty)

I have this serializable class, wich i use to store on a binary file an ArrayList of Strings. public class SaveState implements Serializable{ public static ArrayList favoriteBusStopNumbers = new ArrayList(); public static…
3
votes
3 answers

How to store a class object into Internal Memory Storage using serializable?

I need to store this object into the internal storage memory of the phone, and i have the set on the manifest. The object itself haves two static methods…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
3
votes
2 answers

copying serializable objects without using ObjectOutputStream

I've successfully used ObjectOutputStream and ObjectInputStream to serialize and deserialize objects for a server and client I am writing. The server and client are usually on two different machines, but since It's going to be a turn based card…
bobbaluba
  • 3,584
  • 2
  • 31
  • 45
3
votes
0 answers

Problems with I/O with android (Mostly ObjectInputStream)

First time posting on here so go easy on me! Trying to create a method that reads in omw.data, checks to see if SavedSession object already exists in the file. If it does then ignore it otherwise append it to the end of the file. I am able to add…
Mat
  • 31
  • 5
3
votes
3 answers

program hangs on ObjectInputStream readObject method .

I want to share object of type Stuff which contains ( String name,address,title, ... and byte[] picture ) when connection is established after that my code hangs on objectinputstream readObject() function . No streaming occurs. Can anyone please…
Ahmed
  • 814
  • 2
  • 19
  • 38
3
votes
1 answer

Java serialization. Field changes value

I have the following problem. I can set the transaction state to be either "start, end or ongoing". I set this, then serialise my Transaction object over to the server, who retrieves it. Works like a charm the first time (when the transaction is in…
3
votes
2 answers

Unable to send Object through ObjectInputStream in Java

I am writing an app that makes use of Object Output and Input Streams. However I have a problem, because I am not able to send my object properly. I write it to stream, and server gives me a class not found exception, even though both client and…
BartoszCichecki
  • 2,227
  • 4
  • 28
  • 41
3
votes
2 answers

Java SocketServer with multiple clients - StreamCorruptException

The Application I'm writing a client/server application in Java, that communicates by sending objects over sockets using the ObjectStream classes. Each node in the application looks approximately like this: class Node { SocketServer server; …
wen
  • 3,782
  • 9
  • 34
  • 54
3
votes
1 answer

ObjectOutputStream and java.io.StreamCorruptedException

When I try to send a customobject (See Content.java) from my client to the server with ObjectOutputStream, I get StreamCorruptedException after the first object is sent. So if I try to send another object I get the exception, (it works the first…
user713821
  • 349
  • 5
  • 14
1 2
3
37 38