objectinputstream

Java Socket Programming

I am building a simple client/server application using java sockets and experimenting with the ObjectOutputStream etc. I have been following the tutorial at this url http://java.sun.com/developer/technicalArticles/ALT/sockets starting half way down when it talks about transporting objects over sockets. See my code for the client http:/...

ObjectInputStream Error

I am using ObjectOutputStream to create a file of serialized objects. I then use an ObjectInputStream to with the readObject() method to get the objects back out of the file. It works great the first time. Meaning that if the file does not exist and I open it then append any number of objects, I can open the ObjectInputStream object a...

Appending to an ObjectOutputStream

Is it not possible to append to an ObjectOutputStream? I am trying to append to a list of objects. Following snippet is a function that is called whenever a job is finished. FileOutputStream fos = new FileOutputStream (preferences.getAppDataLocation() + "history" , true); ObjectOutputStream out = new ObjectOutputStream(fos);...

Java - resolve ObjectInputStream

Please tell me how to differentiate objects from ObjectInputStream.Like whether it is String , Image or etc...? ...

Java: Socket close connection and ObjectInputStream

Hi, My code looks like this, this is Server code (Runnable) public void run() { while (true) { try { System.out.println("Waiting for client..."); this.socket = serverSocket.accept(); System.out.println("Client accepted"); while (true) { readCommand(); ...

java - IO on internal class

Is it possible to ObjectOutputStream/ObjectInputStream an internal class? I can write it OK, and examine the created file, but when I try to read it back in using ObjectInputStream, I get an EOFException just trying to read an Object o = oos.readObject(); I use the same File object to open both streams, so that's not the problem. It s...

How can I append to an existing java.io.ObjectStream?

As for now I will get java.io.StreamCorruptedException when I try to append an Object. I have searched the Internet for a way to overcome that. The answer I found so far is it can't be done. A way around this problem is to write the objects into a list and then write the list to the file. But I have to overwrite that file everytime when...

Performance issue using Javas Object streams with Sockets

I'm trying to do local IPC using Sockets and Object streams in Java however I'm seeing poor performance. I am testing the ping time of sending an object via an ObjectOutputStream to receiving a reply via an ObjectInputStream over a Socket. Here's the Requestor: public SocketTest(){ int iterations = 100; try { Socket s...

java.net.SocketTimeoutException: Read timed out

Hi Folks, I have an application with client server architecture. The client use Java Web Start with Java Swing / AWT and the sert uses HTTP server / Servlet with Tomcat. The communication is made from the serialization of objects, create a ObjectOutput serializes a byte array and send to the server respectively called the ObjectInp...

EOFException in ObjectInputStream Only happens with Webstart not by java(w).exe ?!

Hi, Anyone familiar with the differences in starting with Webstart(javaws.exe) compared to starting the app. using java.exe or javaw.exe regarding streams ? This is the exception which i ONLY get when using Webstart : java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) at java.io.Object...

Java FileInputStream ObjectInputStream reaches end of file EOF

I am trying to read the number of line in a binary file using readObject, but I get IOException EOF. Am I doing this the right way? FileInputStream istream = new FileInputStream(fileName); ObjectInputStream ois = new ObjectInputStream(istream); /** calculate number of items **/ int line_count = 0; while( (String)ois...

java.io.EOFException while writing and reading froma servlet

Hello everyone, I have the following code on the applet side: URL servlet = new URL(appletCodeBase, "FormsServlet?form=requestRoom"); URLConnection con = servlet.openConnection(); con.setDoOutput(true); con.setDoInput(true); con.setUseCaches(false); con.setRequestProperty("Content-Type", "application/octet-stream"); ObjectOutputStrea...

Restore previously serialized JFrame-object, how?

Hi all. I have managed to serialize my very basic GUI-object containing a JTextArea and a few buttons to a file 'test.ser'. Now, I would like to completely restore the previously saved state from 'test.ser', but seem to have a misconception of how to properly deserialize an objects state. The class MyFrame creates the JFrame and seria...

Load files bigger than 1M from assets folder

I'm going crazy, I created a file object, so it can be read with ObjectInputStream, and I placed the assets folder. The method works with a file smaller than 1M, and give error with larger files. I read that is a limit of Android platform, but I also know that can be "easily" avoided. Those who have downloaded the game Reging Thunder, fo...

stop thread that does not get interrupted

I have a thread that sits and reads objects off of an ObjectInputStream: public void run() { try { ois = new ObjectInputStream(clientSocket.getInputStream()); Object o; while ((o = ois.readObject()) != null) { //do something with object } } catch (Exception ex) { //Log excepti...

How to store and read an array list of objects in java?

Hi, I am having difficulties w/ writing and reading an array of objects from a file. This is how my object looks like: package registar; import java.io.Serializable; public class Vozilo implements Serializable { private static final long serialVersionUID = -5302010108271068350L; private String registracija; private Stri...

Java: Reading from ObjectInputStream

I have only started learning Java. My task is to create a file server which accepts certain commands like File Get, File Put and File Delete from multiple clients using Threading. I am using a custom class DataObject to serialize and send commands and any data that may accompany with it. The client is to be made interactive in the sense ...

Equivalent of BufferedReader.readNext() for ObjectInputStream in Java

I have a Server communicating with multiple clients through a socket connection. In my original program, messages were sent and recieved using a PrintWriter and a BufferedReader. When I checked to see if any new messages had been received, the BufferedReader would have them all stored and I could read them one by one. I am now trying to...