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.

544 questions
-1
votes
2 answers

How to read objects sent over objectOutputStream on a socket server in Java

I have the send working but the server side wont receive the object sent in the data input stream. The class is serialized and works when sending but I'm not sure why it is not being received by the server. Here is my code: Server.ois = new…
Tyler Songer
  • 52
  • 1
  • 9
-1
votes
2 answers

Reset an ObjectOutputStream in Java

I know this problem has been asked previously, but I can't realize how to send an object more than one time with an ObjectOutputStream, I tried what people said in this forum. The thing is I'm developing a Snake game in Java using multithreading and…
Pepe
  • 27
  • 1
  • 1
  • 7
-1
votes
3 answers

How to find if the file exist or not in Android?

I have write the following code to write a file- FileOutputStream fos = context.openFileOutput("MyFile",Context.MODE_PRIVATE); ObjectOutputStream os = new ObjectOutputStream(fos); //Saving my…
-1
votes
1 answer

Android: OptionalDataException upon ObjectInputStream.readObject()

Situation : From my Android server, I'm sending a simple String OBJECT to the client. I use ObjectOutputStream at the server, and ObjectInputStream at the client. Server code: mOutput.flush(); mOutput.reset(); …
-1
votes
1 answer

one single ObjectOutputStream for multiple use with sockets

I'm trying to make a very basic example of a network connection where I use an ObjectOutputStream, ObjectInputStream and sockets. The client sends the string "Hello" to the server. As you see this string is sent 10 times with the very same…
Sheldon
  • 749
  • 2
  • 5
  • 15
-1
votes
1 answer

Can't use InputStream from Socket after writeObject

Here is the situation: I have a ServerSocket ss, and "Socket socket = ss.accept();", then if I do this: istream = socket.getInputStream(); ostream = socket.getOutputStream(); in = new BufferedReader(new InputStreamReader(istream)); out = new…
Marko
  • 1,110
  • 1
  • 15
  • 25
-1
votes
1 answer

Communicating with multiple clients - Java Server

I have implemented a small Java chatroom program, where clients can communicate with the server. Although multiple clients won't work - I believe this is because a client reserves a socket while connected? Is there a simple way to add multiple…
-1
votes
2 answers

Appending Objects to a .txt file

I was trying out a program that was given in the exercise at the end of the chapter 'Serialization'. The program requires me to declare a class Person which encapsulates only two data members of type Name and Address , which are also classes. Then…
A User
  • 355
  • 2
  • 4
  • 13
-2
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…
-2
votes
2 answers

Reading/Writing objects to file returning null

I'm trying to read and write objects into a file. Reading the output into a new object works, but every value is null. Here's the code: public void read() throws Exception { try { FileInputStream fIn = new…
geger42 _
  • 15
  • 5
-2
votes
1 answer

Cannot see the contents of the array printed in console

public RMI post(PrintStream stream, Object object) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); // oos.writeObject(System.rmi); oos.flush(); …
-2
votes
1 answer

How to Serialize ImageIcon Object?

I am trying to build a client-server Program in which the server sends the image to client and client displays the received image in JFrame. I am converting Image on the server-side to ImageIcon object and sending it to the client via…
ck0049
  • 1
  • 3
-2
votes
1 answer

NotSerializableException when sending an Object

I want to create an instance , put it on a container and send it. TransferContainer container = null; ... Class aClass = container.getByteCode(); o = aClass.newInstance(); ....// Some code ... container.setInstance(o); …
user567
  • 3,150
  • 9
  • 40
  • 71
-2
votes
1 answer

loading file to java application

I am trying to load a file which I saved of a simple class. Below you can find my code which im using to load, the class which I need to cast is NewClientClass. JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(null); …
-2
votes
1 answer

Serializing object with java

I am trying to serialize an object with ObjectOutputStream and FileOutputStream, however an error with the class name is being shown. JFileChooser fc = new JFileChooser(); NewClientClass AddClient = new NewClientClass(IDNumber.getText(),…
1 2 3
36
37