623 questions
1
vote
2
answers
135
views
Deserializing Java object streams with different serial version IDs
I am trying to load data from Java object streams from another application. Since I do not have access to the source code of that application, I used jdeserialize to extract the class definitions from ...
0
votes
2
answers
89
views
How to safely deserialize a List<Compte> with ObjectInputStream without unchecked cast warnings?
I’m working on a Java project where I need to save and load data (a list of Compte objects) using serialization.
My method for loading the data looks like this:
public static List<Compte> ...
0
votes
0
answers
126
views
How to repair a file with java.io.EOFException
I'm not sure what happened when saving a file, but now when I try to load it I get java.io.EOFException. All of the code is in try/catch blocks but there was no error when saving the file.
Opening the ...
0
votes
1
answer
68
views
Optional Data Exception false when reading object from file
I am trying to read objects from file to display them on a jpanel but I am having a hard time deserializing them.
public static void saveFile(Screen screen)
{
JFileChooser find = new JFileChooser()...
0
votes
1
answer
82
views
Continuous Socket connection, ObjectInputStream EOF on second request
Java 21 Sockets allowing for multiple connections using ObjectInputStream and ObjectOutputStream produce EOF on second request
I have a Client side, a (middleman) Bridge Server and an Inventory ...
0
votes
0
answers
81
views
Java Serialization / Deserialization Duplicate Object Problem
I'm writing a large scale program in java where I keep track of the Nodes with different data structures.
Specifically, one of my Node type have 2 left & right pointers for 2 different Binary ...
-1
votes
1
answer
83
views
Why am I getting an end of file exception when trying to use serialization on a hash map in java?
public static void updateNumberOfEpsWatched() throws IOException, ClassNotFoundException
{
String currentDirectory = System.getProperty("user.dir");
ObjectInputStream in =...
0
votes
0
answers
108
views
ObjectInputStream constructor gives StreamCorruptedException: invalid stream header: EFBFBDEF
I am trying to use an ObjectOutputStream and an ObjectInputStream to store multiple BookLibrary objects in an ArrayList, but whenever I attempt to read in the data from the text file ("data.txt&...
1
vote
1
answer
95
views
Why can I not establish the Input/OutputStreams? Java ServerSocket
I have a ServerMain and a ClientMain that give a Socket to a Client and a Server Thread. I then try to make ObjectStreams using the same method but I get an error.
error for ServerMain:
java.net....
0
votes
1
answer
66
views
How to realize the ObjectInputStream::read function's return value
When using Java socket to transfer a file, I set byte[] BUFFER = new byte[1024 * 8], and using objectInputStream.read(BUFFER, 0, BUFFER.length) to receive file stream, but the return value of ...
1
vote
1
answer
110
views
Trans File use java socket, ObjectInputStream and ObjectOutputStream but blocked
Send file with socket BIO use Socket, ServerSocket, ObjectInputStream and ObjectOutputStream but blocked. The detail code is:
Model:
@Data
@ToString
public class FileTransModel implements Serializable ...
0
votes
1
answer
90
views
How to determine the boundary when reading with ois.readObject()
If the sender uses ois.writeObject to continuously send two objects of the same class to the receiver, and the receiver uses oos.readObject to read, is it possible for the receiver to treat the two ...
0
votes
0
answers
35
views
Singleton Serializable Database save method throws IOException
The goal of this class is to be able to load when the program starts and save when data is changed. I have used these same methods before, the save and load ones. For some reason I can not get it to ...
0
votes
0
answers
45
views
How to use ObjectInputStream to find a class instance in a list of instances
I am trying to create an instance of the class Account and it cannot have the same handle as other accounts, which is checked using a for loop which compares the handle passed a parameter to the ...
1
vote
1
answer
291
views
Clear entries on ObjectInputStream in Java -- memory issue
I have a Java program that is supposed to read independent serialized objects from a file (no interdependencies between the objects), process them, then write them as independent serialized objects to ...
1
vote
0
answers
563
views
Gradle missing inputs properties
After update from Gradle 6 to 7.x i cannot solve and find the cause of missing properties. For fields File and File Collection that being annotated @Input
`Reason: A property of type 'File' annotated ...
0
votes
1
answer
191
views
ObjectInputStream returning EOFException when reading List of Object
Im returning a list of all the objects stored in some temporary files in my Android project. When the list its appended the file its deleted.
public static <T> List<T> fileToLogList(...
1
vote
1
answer
46
views
Long is set to null when transmited over ObjectStream from server to client
I have an abstract Entity
public class Entity<ID> {
private ID id;
public ID getId() {
return id;
}
public void setId(ID id) {
this.id = id;
}
}
And a User ...
0
votes
1
answer
63
views
Not sure why I'm getting an EOFException
I'm trying to read objects from a file that I have written to but when reading there's an EOFException that gets thrown. I can see that it reads the objects but halfway through reading the file the ...
0
votes
0
answers
696
views
class java.lang.Boolean cannot be cast to class java.util.ArrayList
I'm trying to read an ArrayList of objects from a BinaryI/O but I keep getting the error "class java.lang.Boolean cannot be cast to class java.util.ArrayList (java.lang.Boolean and java.util....
0
votes
1
answer
50
views
Fail to initialize multiple ObjectInputStream and ObjectOutputStream in Java
I am writing an I/O communication between one server (GameServer) and three clients (GameClient). After the server accepts three clients, it starts a separate thread (HandlePlayer). The HandlePlayer ...
0
votes
1
answer
61
views
Objects not read completely when reading from a File in Java
I'm saving objects from two array lists to a file and if I restart the application I have called a read method at the startup which will read the data from the file and add them to the array lists
But ...
1
vote
0
answers
168
views
Java Stream Corrupted error when iterating through Serialized file to deserialize [duplicate]
I initially created a file containing serialized data, and wanted to iterate through it and add the objects to a text file. However, I keep getting a StreamCorrupted error when I try doing so. Any ...
0
votes
0
answers
221
views
add files to root and access it within Android Studio Project
in java you could add the file within the project so you could use it on any device, i.e if the file is "data.dat" in java I could put the file in the project root and write this line
try (...
0
votes
1
answer
46
views
Cannot get stream in socket java [closed]
Source:
while (true) {
System.out.println("Waiting");
ois = new ObjectInputStream(socket.getInputStream());
System.out.println("Rcvd Stream");
client listener....
0
votes
0
answers
151
views
Read file content into Arraylist using ObjectInputStream
I am a beginner in java and practicing IO stream and Serialization .In below problem unable to read all data into a Arraylist and print it. by using the ObjectOutputStream insert the content by user ...
0
votes
0
answers
297
views
java.io.StreamCorruptedException: invalid type code: 40
I'm building software that passes objects over a TCP socket in Java - using the ObjectInputStream/ObjectOutputStream API.
Although, after a minute of smooth communication I started to get the ...
0
votes
1
answer
69
views
StreamCorruptedException reading a resource file only in a Spring Boot application
On a Spring Boot application (2.3.3), I have a dependency to a module developed by my company. From a service I'm calling a method from this dependency which needs a file loaded from resources (src/...
0
votes
0
answers
113
views
writing and reading object in a binary file
I am making a program where user inputs his/her info and it is written in the file in binary form and after that we ask for a name whose info we want to get from the file. In that I take all the ...
1
vote
1
answer
104
views
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 ...
0
votes
1
answer
63
views
Problem with reading array of objects from file
i have a class writeStudent like this:
package test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io....
1
vote
1
answer
151
views
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;
...
0
votes
0
answers
45
views
ClassNotFoundException using ObjectInputStream and data class
so I have problem with my connection between Server module and Client module.
I have 2 data classes to read it from ObjectInputStream and send with ObjectOutputStream
unfortunatelly it can't find my ...
0
votes
1
answer
678
views
Why doesn't the ObjectOutputStream write the variables in the file as intended? [duplicate]
I am learning Java and I'm trying to get a programme to write the attributes of one class instance of another into a .txt file, like a phonebook for instance. I have a class User :
package idpack;
...
0
votes
0
answers
53
views
Writing and reading Bytes AND Objects between sockets without deprecated methods in Java
I am trying to make a web servers cluster in Java. The first thing a server does after it starts running is ask another one to join the cluster. In this process, a copy of the WebServer object itself ...
0
votes
0
answers
899
views
Reading Java Stream Objects from input stream
I have a problem with java.lang.Object stream. InputStream actually is a real Object[]. readObject method reads only one object. How can I read stream objects correctly? Sample code is below.
...
-1
votes
1
answer
268
views
How to Serialize and Deserialize multiple objects in Java during runtime
I am creating a Login Form and Sign up Form using JFrames.
The problem is every time when the user presses the Sign up button the user details should be serialized and added to the "users.ser&...
0
votes
0
answers
89
views
Server doesn't receive client Object java
i have a server that work if change String with clients. Now,i want to use Object instead of String but the server doesn't receive anything and get stugged before the sout like the client doesn't sand ...
0
votes
1
answer
36
views
ObjectInputStream isn't finding any data to pull?
I am trying to read and write shape objects to a file for a drawing program, but when I try to read from the file it shows that the file is empty. The file is definitely being written to and updated, ...
0
votes
1
answer
115
views
Java socket getting only NUL characters after writing byte array
I'm trying to send files in chunks from a client to server via byte arrays. I'm using ObjectInputStream. The write works and the filesize matches but when I open the file, I only get a blank textfile(...
0
votes
0
answers
499
views
How to convert Google Tink KeysetHandle to byte[ ] and back?
I'm trying to convert Google Tink's KeysetHandle into byte [] and to construct the KeysetHandle back from the byte [].
So here is the code I came up with
//Two functions for the conversion
public ...
0
votes
1
answer
572
views
Looping through a ObjectInputStream in one method and print entire file in the main method, but having problems with EOF not working or erroring
So I have a working ObjectOutputStream in a method that I start by calling the method in main. I need to then read the file it created and print out all 5 objects in it. Right now I'm only printing ...
-1
votes
1
answer
5k
views
java.io.EOFException when reading from socket
I have a server and a client set up in this way. I can't find the cause of the EOFException, because it happens randomly. It throws the following exception every time a client connects, but I can't ...
1
vote
1
answer
758
views
unexpected behavior from custom ObjectInputStream when reading object with LocalDate field
i'm using the example from this repo https://github.com/kojenov/serial/tree/master/3-4.%20upload, which is presenting a method for specifying a way to protect form unsafe deserialization in Java by ...
3
votes
0
answers
253
views
readObject returns same object every time
I am writing objects as needed to a file using ObjectOutputStream. However, I am only able to read the first object that is written to the file, even though several objects are added to the file. This ...
1
vote
1
answer
444
views
ObjectInputStream Error: StreamCorruptedException
I am making an instant messaging application where I set up a TLS connection between two phones where one acts as a Server and the other as the Client. When trying to send a message I get this ...
0
votes
0
answers
28
views
Storing a File object into a Serializable Object via TCP
Hello does anyone know how to put a File object to a serializable object that can be passed through TCP connections? I currently have a Message object that can pass an Image and a String, now i want ...
0
votes
2
answers
549
views
ObjectInputStream not reading full file after appending data
I am writing a small program that inserts customer details in ArrayList and write it in file.
The problem is with ObjectOutputStream I was able to append data in file with turning FileOutputStream(&...
1
vote
2
answers
2k
views
Having A problem with reading my public and private key files
I have a method in an encryption class that is responsible for reading my RSA key files and there respective components. To do this is use an InputStream object with an ObjectInputStream object. These ...
0
votes
1
answer
68
views
EOFException with ObjectInputStream
I have read other questions similar to this but didn't help much. So I have some serialized content in a file and I am trying to read it and print it on the console, content is getting printed fine ...