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
1
vote
0 answers

java read arrayList - objectInputStream EOFEXception

Hi i am trying to read an ArrayList of Integer and get EOFException. i have a ArrayList of Question which is serialized and i do the same thing for reading it no problem, but with ArrayList Integer dont work. i write the two ArrayList like so: (im…
Din Salman
  • 11
  • 2
1
vote
1 answer

Java: EOFException in networking

I am new to networking and I am getting an EOFException when I am trying to run the MyClient.java. MyServer.java public class MyServer { public static void main(String[] args) { ServerSocket serverSocket = null; try { …
skip
  • 12,193
  • 32
  • 113
  • 153
1
vote
0 answers

retrofit2: java.io.EOFException even when Postman works fine

I'm trying to retrieve data from an API using an endpoint that works on Postman. However, when I use it on Retrofit I get the EOFException. (using also interceptor to add a bearer token) MyInterface: interface ITerminalAPIService { …
JMarques
  • 11
  • 2
1
vote
3 answers

Nothing being written to a .dat file

I am trying to create a program that reads a .dat file containing a HashMap object. If the .dat file is empty, it should write an empty HashMap object to the file, then, it should give the user options to edit the HashMap object. When I tried this…
iNoob
  • 27
  • 8
1
vote
0 answers

java RandomAccessFile EOFException

I am trying to check whether a certain position in RandomAcceessFile is empty in order to avoid overwriting some data before writing in the file. I initialized a very large RandomAccessFile: randAccFile = new RandomAccessFile( DIR + "/" + FILENAME,…
vcucu
  • 184
  • 3
  • 12
1
vote
1 answer

Why DataInputStream can't read char correctly?

I tried to write String in DataInputStream, when read from DataInputStream single char, but I have an error. I expected, that readChar() return 'q', but method: assertEquals('q',…
1
vote
0 answers

Java write a byte array with given ObjectOutputStream

I have a serializable class with custom writeObject() and readObject() methods. When an object serializes, it needs to write two byte arrays, one after another. When something deserializes it, it needs to read those two arrays. This is my…
1
vote
1 answer

java.io.EOFException: Unexpected EOF read on the socket

We are observing a lot of these errors in the logs. java.io.EOFException: Unexpected EOF read on the socket Following is the protocol configured in the server.xml of Tomcat8 Instance: org.apache.coyote.http11.Http11Nio2Protocol. Do we have to…
Pradeep Pydi
  • 9
  • 1
  • 5
1
vote
1 answer

Java: Prevent Socket DataInputStream from throwing EOFException

My client/server application currently keeps opening and closing new connections every time it wants to send/receive data. I'm trying to change it so it will have one persistent connection. The problem I'm having is the socket's DataInputStream…
user489481
  • 321
  • 1
  • 4
  • 13
1
vote
1 answer

Writing/Reading from a randomaccesfile

I have a project where I am to write data (strings and ints) into a binary random access file, and read the data in a separate class. The problem I have is I'm trying to iterate through the file and read the data in a specific order (int, String,…
Jengland
  • 33
  • 1
  • 6
1
vote
1 answer

Hbase 0.20.6 Can not start master exception

I'm using Hbase 0.20.6 with Hadoop 0.21.0 on Ubuntu 10.04 LTS and I got can't start master error. (The error is attached at the end of the post from the hbase-root-master-ubuntu.log file) Does Hbase 0.20.6 work fine with Hadoop 0.21.0 ?? and if it's…
1
vote
2 answers

Weird EOF Exception while trying to download file from GWT application

I am trying to download a file from GWT client. At server side there is a servlet which generates content of file as per request and send it back to the client. Test Scenarios: Scenario 1 If I hit url of servlet directly, it always give me…
Tarun
  • 11
  • 3
1
vote
2 answers

EOFException thrown by a Hadoop pipes program

First of all, I am a newbie of Hadoop. I have a small Hadoop pipes program that throws java.io.EOFException. The program takes as input a small text file and uses hadoop.pipes.java.recordreader and hadoop.pipes.java.recordwriter. The input is…
peng
  • 131
  • 2
  • 10
1
vote
1 answer

EOFException when sending ObjectOutputStream

I'm trying to send a blank TCP packet to a server running on port 80 however it gives me an EOFException when the server responds. java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2624) …
Adam
  • 143
  • 3
  • 18
1
vote
0 answers

EOFException in Java using JPBC library for ABE

I am trying to run an example of Attribute-Based Encryption using the JPBC library found here using eclipse: JPBC ABE. When i run the code i get the following error Exception in thread "main" java.lang.RuntimeException: java.io.EOFException at…
Mr.stark
  • 31
  • 5