objectoutputstream

Sending the same but modifed object over ObjectOutputStream

I have the following code that shows either a bug or a misunderstanding on my part. I sent the same list, but modified over an ObjectOutputStream. Once as [0] and other as [1]. But when I read it, I get [0] twice. I think this is caused by the fact that I am sending over the same object and ObjectOutputStream must be caching them som...

Object(Output|Input)Stream binary protocol

I was wondering if anyone had some resources that describe the binary protocol used by ObjectOutputStream. I realize of course that objects themselves can specify what their data by implementing the Externalizable interface, so I guess I'm looking more toward the structure of the object graph - the metadata if you will. I am writing a C...

NullReferenceException when sending XMLWrite output to httpContext.Response.OutputStream

I have an application where every now and then I'm getting a strange error. This is the piece of code: Dim XMLWriter As New System.Xml.XmlTextWriter(Me.Context.Response.OutputStream, Encoding.UTF8) XMLWriter.WriteStartDocument() XMLWriter.WriteStartElement("Status") Message.SerializeToXML(XMLWriter) XMLWriter.WriteEndEl...

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...

OutputStream delete file contents JAVA

I have files in who i need to record serialized object. I open ObjectOutputStream for writing in files. If i didnt wrote nothing in file, file content get deleted. I don't want content to be deleted when i make ObjectOutputStream. Any help? Edit: @Provides @ArticleSerializationOutputStream public ObjectOutputStream getArticleObjectOutp...

How to override ObjectOutputStream.writeStreamHeader()?

The method ObjectOutputStream.writeStreamHeader() can be overridden to prepend or append data to the header. However, if that data is based on an argument passed to the derived class's constructor like: public class MyObjectOutputStream extends ObjectOutputStream { public MyObjectOutputStream( int myData, OutputStream out ) throws...

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: Use ObjectOutputStream without serializable

Hello, Sometimes, I want to use an ObjectOutputStream to write something to a file or sending a little image over the network. But BufferedImage and many other classes not implement java.io.Serializable and then the Stream cancels writing. Is there a way avoid that? Thanks, Martijn ...

writing a BitSet to a file in java

I have a BitSet and want to write it to a file- I came across a solution to use a ObjectOutputStream using the writeObject method. I looked at the ObjectOutputStream in the java API and saw that you can write other things (byte, int, short etc) I tried to check out the class so I tried to write a byte to a file using the following code...

Java: ObjectOutputStream with Serializable problem

Hello, I have these three classes: Command: package pack; public abstract class Command impements java.io.Serializable { public abstract void execute(); } Client: package pack; // imports.... public class Client { Socket socket; // Constructor... public void sendCommand(Command c) { try { ...

save Linked List in Notepad.txt

I draw many triangle polygons and store it in Linked List. My problem is that, when I store the drawing in a Notepad file, the data is unreadable (weird symbol). When I try to print it using println the output is like this java.awt.Polygon@1d6096. How to store the coordinate of the polygon in Notepad? ... java.util.List<Polygon> tri...

Help me MAKE C# Monitor (Output) and Feed (Input) to SSH.exe

I've found that the more I refine a question, the better help I get. So, to make the question as complete as possible, I'm providing this C# WPF solution created in Visual Studio 2010 Beta 2. This solution exactly reproduces the problem I'm having, as I try to capture output from ssh.exe using the System.Diagnostics.Process object. To...

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...

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 = null; while(( o = inputStream.readObject()) != null){ Term t = (Term)...

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...

create object output stream from an object

Hi, I want to create on ObjectOutputStream, but I don't want to persist the object in a file, so how to do that? All the tutorials(that I found) say only about the file way: FileOutputStream fos = new FileOutputStream("t.tmp"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(new Date()); ...

Strange Java Socket Behavior (Connects, but Doesn't Send)

I have a fairly complex project that boils down to a simple Client / Server communicating through object streams. Everything works flawlessly for two consecutive connections (I connect once, work, disconnect, then connect again, work, and disconnect). The client connects, does its business, and then closes. The server successfully close...

ObjectOutputStream .writeObject

hey i have some problems with this code... This is a JDialogForm in which I have jTextField and button. I want to save data from this Jtextfield when i click button to use it in another window but i don't know why it doesn't work. I always get Exception ek and the message i have put there. private void jButton1ActionPerformed(java.awt...

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...

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...