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
1
vote
1 answer

Object output and input issues, only prints the first line on the input

I'm making a chat server for a class and am having issue logging messages for offline users. The data appends to the logfile as an object, it grows in size as you log more. When I login as the user who received a message it only returns the first…
1
vote
1 answer

Getting "java.io.EOFException" after sending a file throught socket

I'm trying to implement basic communication through sockets, what I have now is: server start's to listen on socket, this.serverSocket_ = new ServerSocket(this.serverPort_); clientSocket = this.serverSocket_.accept(); client connects, and server…
WojtusJ
  • 1,318
  • 1
  • 12
  • 19
1
vote
2 answers

NotSerializableException when sending an serializable object over socket?

Im trying to send a custom-made object over a socket connection. The class implements serializable but the constructor still throws a NotSerializableException when im trying to write the object to the socket. I'll post relevent code below: public…
John Snow
  • 5,214
  • 4
  • 37
  • 44
1
vote
1 answer

Long is set to null when transmited over ObjectStream from server to client

I have an abstract Entity public class Entity { private ID id; public ID getId() { return id; } public void setId(ID id) { this.id = id; } } And a User which inherits from Entity public class User extends…
1
vote
1 answer

Cannot recieve objects that contains other objects with ObjectInputStream in Java

I try to use ObjectInputStream and ObjectOutputStream in my Java project but the object I want to send on the network contains other objects than String, int, boolean etc... so it does not work when I try to deserialize it. Do you know other…
Akashiro
  • 11
  • 2
1
vote
1 answer

Why is deserialized object's size different from serialized object's size?

I'm saving some Java objects in files. I seralize them that way : Class Timestamp.java: public class Timestamp implements java.io.Serializable { private static final long serialVersionUID = 1L; private static SimpleDateFormat staticFormat =…
E.F
  • 199
  • 1
  • 1
  • 10
1
vote
2 answers

How to read Java ObjectOutputStream generated file from File System?

I'm new to Programming world and was exploring JAVA File I/O operation but found strange thing that when I'm trying to read ObjectOutputStream generated file from File System it is showing Byte Array sort of data instead of text redable data. Please…
DevNadim
  • 31
  • 4
1
vote
1 answer

Can't Cast a POJO after ObjectOutputStream

I have a program that sends POJO from a server to a client. For primitive data types like String[] or Boolean it works fine. When I create a custom data type with just getters and setters, send it from server to client and try to cast it from a Java…
1
vote
2 answers

Appending to ObjectOutputStream (writing multiple objects w/o closing stream)

Desclaimer My question is different from two following links Question 1 Question 2 public class AppendableObjectOutputStream extends ObjectOutputStream { public AppendableObjectOutputStream(OutputStream out) throws IOException { …
MoveFast
  • 3,011
  • 2
  • 27
  • 53
1
vote
0 answers

Listening a DefaultTableModel for any change in its data and then saving it to a file

Looking but didn't get the answer so far. Here there is a class having a DefaultTableModel private static DefaultTableModel defaulttablemodel = new DefaultTableModel(); defaulttablemodel.addColumn("Column 1"); defaulttablemodel.addColumn("Column…
Snowman
  • 17
  • 2
1
vote
1 answer

How do ObjectOutput/ObjectInput Streams work?

I'm trying to make a Client/Server chat application using java. I'm pretty new to using sockets to communicate between applications. I've decided to use ObjectInput/ObjectOutput streams to send objects between the client and server. I'm trying to…
1
vote
0 answers

Java - Writing Object in res folder will instead of writing it in bin

Im having problems writing/reading object as resources on file. I run code from the Main.java Class, and I want to write/read an object to the users.txt file. The object that I want to write/read is the TryStructure Object, which just incapsulates…
StefanoN
  • 147
  • 1
  • 7
1
vote
0 answers

How do I write to a memory mapped file using a writeExternal (Externalizable interface) method?

I hava a memory mapped file where I can write values as follows: public class HelloWorld{ public static void main(String []args){ try { // OPEN MAPPED MEMORY FILE file = new…
M.E.
  • 4,955
  • 4
  • 49
  • 128
1
vote
2 answers

Unable to serialize convert java POJO class into a byte array

How to convert java POJO class into a byte array as I wanted to save the object into a gz file in S3 I get this exception Caused by: java.io.NotSerializableException public byte[] compressData(User user) throws IOException { byte[]…
Harish
  • 565
  • 1
  • 12
  • 34
1
vote
1 answer

java: keep tracking of file size on the run?

I wrote a code that writes compressed objects into a file, My questions is: is there a way that I could keep track of the increment of size of my file as the object being wrote in? here is my code: public static void storeCompressedObjs(File…
user685275
  • 2,097
  • 8
  • 26
  • 32