Questions tagged [eofexception]

An exception that occurs when reading from a stream or file, and indicates that the end of the stream has been reached. For example, you had expected to read 4 bytes from a stream with DataInputStream.readFully(), or an object with ObjectInputStream.readObject(), but end of stream was encountered instead.

An exception that occurs when reading from a stream or file, and indicates that the end of the stream has been reached. For example, you had expected to read 4 bytes from a stream with DataInputStream.readFully(), or an object with ObjectInputStream.readObject(), but end of stream was encountered instead.

Even though the exception is named EOF for 'end of file', it is possible to get this exception when processing any data stream. The exception can occur as a result of many different actions, such as:

  1. Reading data from a socket connection that has already been closed by the peer and all prior pending data has already been read.
  2. Reading data from an empty file.

When reading from a stream, you should usually detect and handle this exception, as well as other stream-related exceptions such as timeouts, by wrapping your reads in a try-catch block. This will allow you to catch exceptions such as this, and perform an alternate operation, such as alerting the user of the error, or ending the logical connection at this end.

214 questions
0
votes
2 answers

Java streams with EOFException

I wrote some client - server program, that shares data but at server side i got EOFException after reciving data. I tried to fix it on my own but it is hard to find own errors. The error is caused by this line: Message command =(Message)…
Filip
  • 49
  • 2
  • 7
0
votes
1 answer

EOFException error at reading a RandomAccessFile

I am having some issues at reading bytes from with readInt() when using RandomAccessFile whenever I want to print the File I get EOFException. The same error appears in the last catch Statement when I want to show the updated series of numbers. Here…
Ortharios
  • 610
  • 1
  • 5
  • 10
0
votes
2 answers

ObjectInputStream catch block produces EOFException?

Sorry to drag this up but I have had a good look around and I still keep getting an EOFException. I've commented everything out of my method apart from: File receivedFileObject; File newFile = new File("newlyWrittenFile.mp3"); try{ …
James C
  • 464
  • 1
  • 4
  • 12
0
votes
2 answers

java.io.EOFException on FileOutputStream

I have a class that reads the written output of a Student[] array object here is the code import java.io.*; // I use this class to read the final ouput "students_updated.dat" public class StudentArrayObjectFileReader { public static void…
Jer Yango
  • 582
  • 2
  • 8
  • 22
0
votes
1 answer

Java ActiveMQ sending large Object throwing EOFException

Getting java.io.EOFException while sending a large java object using AciveMQ. Below is the large object that I am trying to send class TestDataBean implements Serializable { private String testName = "TestName"; private String testDesc =…
Aryan
  • 1,767
  • 2
  • 22
  • 39
0
votes
3 answers

How can a server know when the message it receives is actally over?

I'm trying to implement a server and it does something like this when it receives a message: try{ ObjectInputStream is = new ObjectInputStream(clientSocket.getInputStream()); String message = (String)is.readObject(); …
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
0
votes
1 answer

EOFException on file based inter process communication

Process-A writes bytes to a data-file using FileOutputStream. Process-B reads from the same data-file using DataInputStream. The data-file resides on a NFS mount that doesn't support FileLocks so following approach is used: Process-A creates a lock…
Debajyoti Roy
  • 985
  • 2
  • 12
  • 34
-1
votes
0 answers

EOFException while deserializing a class

I have a class which has variables that are instances of classes such as vector, hashtable etc. Code to serialize: CRC32 checksum = new CRC32(); try { // serialize the object tree to a byteArray so we can get a checksum ByteArrayOutputStream…
Jitesh
  • 232
  • 2
  • 9
-1
votes
1 answer

EOFException while reading object from ObjectInputStream?

I am inserting a serializable object obtained from de-marshalling an xml. For inserting the object, I use the below methods namely insertPOJOInBackend(). However, while retrieving the object using the method readPOJOFromBackend(), I am getting a…
-1
votes
1 answer

EOFExeption when reading own object from server

I have established a connection via sockets between two computers. I have created an own object called "Result" and I can successfully transfer it to the server computer from the client computer. If I do this socket connection only on my computer…
Henx
  • 1
  • 1
-1
votes
1 answer

Creating ObjectInputStream from Socket throwing EOFException

I will try to put it simply. Class constructor 'B' is recieving a socket as parameter, it is coming from class 'A'. In A, the socket is used for I/O using DataInputStream and DataOutputStream. Neither the socket nor the streams are been closed by…
-1
votes
1 answer

I want to read object created in my file using ObjectInputStream ,But it gives exception that java.io.EOFException

I have successfully created an object in a file using ObjectOutputStream but when i try to read that obj it gives an exception. Please help I am unable to handle this::java.io.EOFException public class ObjInputObjOutput { public static void…
coc champ
  • 69
  • 2
  • 9
-1
votes
1 answer

EOFException at GsonResponseBodyConverter with errorBody()

I'm following DeserializeErrorBody.java as a guide When I use Converter errorConverter, Error being a POJO class for my errors, I would get an EOFException trying to do errorConverter.convert(response.errorBody()); with the log…
-1
votes
1 answer

EOFException while decrypting object using CypherInputStream & ObjectInputStream from file

fist of all I have written one object in file using FileOutputStream,CipherOutputStream & ObjectOutputStream. the flow of code is something like this Object > ObjectOutputStream > CipherOutputStream > FileOutputStream > File. now when I tried to…
-1
votes
1 answer

Exception in thread "main" java.io.StreamCorruptedException: invalid type code: AC

Just trying to read a number. I'm implementing Serializable and my main() throws an error: Exception in thread "main" java.io.StreamCorruptedException: invalid type code: AC at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1379) …
JCoder
  • 189
  • 1
  • 3
  • 17
1 2 3
14
15