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
51
votes
2 answers

Facebook SDK 3 EOFException

I am using the new FaceBook SDK 3.0. While posting images from the URL to "me/photos", I am intermittently getting an EOFException. I am getting this error once in a while (~1 in 20 times). I must also add that just after getting the EOFException…
Gaurav Vashisth
  • 7,547
  • 8
  • 35
  • 56
40
votes
4 answers

Android HttpsUrlConnection eofexception

I have a problem where my HttpsURLConnection will throw an EOFException when i try to read any input. The code works for some network calls, but fails on others. If i try and read anything from the connection, it fails with the aforementioned…
user1883083
  • 841
  • 1
  • 8
  • 10
27
votes
3 answers

EOFException in Retrofit while executing synchronous PUT requests

In my app I make synchronous PUT requests using the Retrofit library. The problem is: sometimes the library throws EOFExceptions. Below is a stack trace for one of such cases 29099-29269/com.mycompany.myapp D/Retrofit﹕ java.io.EOFException at…
Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
17
votes
5 answers

When will an EOFException occur in JAVA's streams

I am working with a DataInputStream and had a question about EOFExceptions. According to java docs: Signals that an end of file or end of stream has been reached unexpectedly during input. This exception is mainly used by data input streams…
jbu
  • 15,831
  • 29
  • 82
  • 105
15
votes
12 answers

Android HttpURLConnection throwing EOFException

Here's the question in simplest way. I create a HTTPS connection to my server through proxy using HttpUrlConnection Object. My proxy closes the connection but my code still tries to reuse the same connection. And so I get EOFException. How do I…
Sudarshan Bhat
  • 3,772
  • 2
  • 26
  • 53
11
votes
5 answers

Java Mysterious EOF exception with readObject

The following code produces an EOFException. Why is that? public static Info readInfoDataFromFile(Context context) { Info InfoData = null; FileInputStream fis = null; ObjectInputStream ois = null; Object object = null; if…
AZ_
  • 21,688
  • 25
  • 143
  • 191
6
votes
1 answer

How low disk space can cause java. io. EOFException

Today I have came across strange behavior in java serialization and deserialization("strange" because I don't understand) I was serializing and deserializing an object from a linux shared directory. While serializing everything worked without any…
Dangling Piyush
  • 3,658
  • 8
  • 37
  • 52
6
votes
1 answer

How to add picture to pdf file using PDFClown

I use PDFClown .jar library in order to convert jpeg images to pdf files. However, I get the below error: java.lang.RuntimeException: java.io.EOFException Here you can find the code: org.pdfclown.documents.contents.entities.Image image =…
Milad-Irani
  • 73
  • 1
  • 5
6
votes
4 answers

java.io.EOFException when try to read from a socket

i don't know why java.io.EOFException appear. i want to write a file after i get binary stream from server. Here's my code inputStream = new DataInputStream(new BufferedInputStream(connection.getInputStream())); FileOutputStream fos = new…
Yusuf1494
  • 252
  • 1
  • 5
  • 16
5
votes
3 answers

Is Java's EOFException exceptional?

It seems dirty to use an exception to indicate the end of a file has been reached. Every file we read has an end, so it doesn't seem exceptional or unexpected. Furthermore, I don't like using an exception for the non-exceptional flow of my…
Mr. White
  • 51
  • 1
  • 3
5
votes
1 answer

A better way to handle Unexpected EOF read on the socket in file upload?

I use Spring MVC to implement file upload on the back-end, and the front end is simply a regular HTML
file to upload:
Dino Tw
  • 3,167
  • 4
  • 34
  • 48
5
votes
1 answer

org.hibernate.type.SerializationException: could not deserialize java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully

I want to query all instance of the entity Translation, which has reference to the entity Text. But, despite marking the Entity class with Serializable, hibernate complains. Why is that? FYI I added Serializable to all of my Entity classes. The…
feder
  • 1,849
  • 2
  • 25
  • 43
5
votes
2 answers

EOFException in readUTF

I am getting below EOFException while using readUTF() method, please let me know how could i overcome with this problem and also please suggest how readUTF() transfers socket information over the other networks import java.io.*; import…
raja shekar
  • 61
  • 1
  • 1
  • 2
4
votes
4 answers

EOFException in connecting to HDFS in hadoop

I am, in the included test program, attempting to copy a file from the local disk to HDFS. The code is as follows: package foo.foo1.foo2.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import…
david
  • 139
  • 1
  • 1
  • 9
4
votes
3 answers

Writing to Avro Data file

The following code simply writes data into avro format and reads and displays the same from the avro file written too. I was just trying out the example in the Hadoop definitive guide book. I was able to execute this first time. Then I got the…
Sri
  • 201
  • 2
  • 4
  • 6
1
2 3
14 15