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

I'm not able to pinpoint the error I'm getting trying to construct FileInputStream. I'm relatively new to programming

I'm working on a homework assignment for my CS java class, and I'm receiving the errors listed below. Below the second horizontal line is the source code. There is an additional java program file that's used to run Crypto.java called Lab13.java, and…
0
votes
1 answer

EOFException - Server/Client readUTF problems

I've recently become interested in trying to adapt my Rock-Paper-Scissors game into a multiplayer-friendly program, so today I decided I'd look up a tutorial on servers. It seems I'm following it precisely (aside from using a different IDE).…
ShowALK
  • 1
  • 2
0
votes
2 answers

Why am I getting an EOFException in my Java code?

I am trying to read a csv file and having the output shown in the console. However, I can't understand why I am getting an end of file exception and nothing is being shown in the console? The Exception message is: java.io.EOFException at…
user2840682
  • 381
  • 2
  • 11
  • 23
0
votes
2 answers

http.request keep giving me EOFError?

I was trying to do something interesting like: http = Net::HTTP.new("t66y.com", 80) request = Net::HTTP::Get.new("http://t66y.com/") response = http.request(request) puts response.inspect it works fine, and give me
LeoShi
  • 1,637
  • 2
  • 14
  • 24
0
votes
1 answer

How can i know when a socket is idle?

I'm trying to write a client server application. the clients post service requests and the server receives them and display them in a tech room. everything was fine until I tried to send a screen capture to a special admin client, that should…
David Gidony
  • 1,243
  • 3
  • 16
  • 31
0
votes
2 answers

How to initiate an update for clients by the server in java

I have a client/server app to manage a line of some sort. all the clients add objects to my line. I want the server to send a screen capture of the jpanel to the clients every time there is a change in the line, line inserted or removed. I managed…
David Gidony
  • 1,243
  • 3
  • 16
  • 31
0
votes
0 answers

Error in FileUtils.copyUrlToFile

I am executing the below code to pull the .gz file from a URL to a local directory.For small files it goes through fine but for large files it downloads only part of it but does not fail. I get to know the error only when I try to UNZIP it. Can…
user3072054
  • 339
  • 2
  • 6
  • 17
0
votes
1 answer

datainputstream for EOFException on the last line of the file

I try to write a data file, whitch will contain: level x1 y1 x2 y2 rgbcolorcode x1 y1 x2 y2 rgbcolorcode x1... etc level - int x1-y2 are doubles rgbcolorcode is an int. but with the code below i get an EOFException on the very last line. private…
cc2k
  • 351
  • 1
  • 2
  • 12
0
votes
2 answers

ObjectInputStream being initialised causes an EOFException of the type IOException

I have been writing a to-do list app in java and each todo item is stored as an object of the class ToDo (which I created). The ToDo class is serializable and I am using an ObjectOutputStream to write the objects to a text file. I close the…
notquiteamonad
  • 1,159
  • 2
  • 12
  • 28
0
votes
1 answer

Java ObjectInputStream refill: StreamCorruptedException in stead of EOFException

I was wondering, why does refill() throw a StreamCorrruptedException when it finds an unexpected EOF in the middle of a data block? (ObjectInputStream.java:2538) Wouldn't it be better if it throws an EOFException or is there a different reason to…
Rik Schaaf
  • 1,101
  • 2
  • 11
  • 30
0
votes
1 answer

getInputStream throws EOFException when sending JSON request

I get an EOFException from getInputStream in the following Android Code. private void downloadUrl() { HttpsURLConnection conn = null; DataOutputStream printout = null; try { try { conn = (HttpsURLConnection) new…
user2813286
  • 15
  • 1
  • 4
0
votes
0 answers

Android loading array list of string arrays EOF Exception

I'm loading an ArrayList using ObjectInputStream in my application. Weirdly, it seems to have worked fine up until recently. I can't see what's causing it. Here are the snippets of code involved: protected ArrayList LoadDetailList() { …
public static void
  • 1,153
  • 11
  • 20
0
votes
0 answers

Android: EOFException on empty response

I'm using the following code. (ServiceResponse is an object just to wrap the response) protected ServiceResponse executeHttpPostRequest(URL url, Map parameters) throws IOException { String charset = "utf-8"; …
fr4gus
  • 396
  • 7
  • 18
0
votes
2 answers

HessianConnectionException: 500 Caused by: java.io.EOFException (Android)

I'm using a hessdroid proxy to communicate between my android application and my webservice/hessianservlet. It works immediatly after starting the app, but when I wait a minute and let the app call a network function again (e.g. logout()) I get this…
trek711
  • 207
  • 3
  • 11
0
votes
1 answer

Reading multiple objects from file

Is there a proper way of reading objects from file using the ObjectInputStream. The examples I've seen seems to rely on that exception is caught to end the reading. While it maybe works it does not seem to be a clean solution as in exception…
starcorn
  • 8,261
  • 23
  • 83
  • 124