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
3 answers

DataInputStream giving java.io.EOFException

I have created small CLI client-server application. Once the server is loaded the client can connect to it and send commands to the server. The first command is to get list of files that server is loaded with. Once the socket connection is…
ChamingaD
  • 2,908
  • 8
  • 35
  • 58
1
vote
1 answer

EOFException while Deserializing object

I have created a method writeFile which writes directly to a File if the flag is true. If the flag is false it reads the File, retrieves the Object, appends something and again saves it to the File. I am getting EOFException when the flag is…
vertexion
  • 536
  • 2
  • 7
  • 20
1
vote
2 answers

EOFException when reading serialized file in Android

I have been looking for an answer to this question but none of others answers worked for me. I am using serialization in android and I serialize one object. Problem is that when I deserializing it I get EOFException and the object won't load. My…
Rasputin
  • 25
  • 4
1
vote
2 answers

HttpsUrlConnection EOFException

I'm using the following code for post requests public String executeHttpPost(String uri, String data) { HttpURLConnection conn = null; URL url = null; String s = null; try { url = new URL(uri); conn =…
Valeriy
  • 785
  • 2
  • 10
  • 28
1
vote
1 answer

EOFException with FileUtils.copyURLToFile

I am trying to download the file to local disk from the URL. So I'm trying to use the FileUtils.copyURLToFile(new URL(url), filename); But I get IOException Occurred java.io.EOFException: End of input or Premature EOF often without complete…
user3161879
  • 103
  • 1
  • 17
1
vote
2 answers

Strange behavior of EOFException

I have some simple class that is DataInputStream stream to read from file. I have surrounded this stream with EOFException try-catch block. It has some strange behavior coz sometimes it throws EOFException into text that is read. Output to…
catch23
  • 17,519
  • 42
  • 144
  • 217
1
vote
1 answer

EOFException after calling socket.shutdownOutput()

like the headline says I´m getting an EOFException on the serverside after i called shutdownOutput() at the clientside this is at the serverside: public void getRestaurant() { String tempRestaurant=null; try { BufferedReader fr = …
Sebastian Walla
  • 1,104
  • 1
  • 9
  • 23
1
vote
1 answer

ObjectInputStream.readObject() EOFException

I'm trying to send a HashMap from a client process to a server process using a DatagramSocket, but I'm getting a ObjectInputStream.readObject() EOFException. I found lots of references to other people having this problem, but I'm having a hard time…
Dan Forbes
  • 2,734
  • 3
  • 30
  • 60
1
vote
4 answers

EOFException and FileNotFoundException in HttpURLConnection getInputStream()

When trying to connect to http://ws.audioscrobbler.com/2.0/ with post data using HttpURLConnection, I get (randomly) EOFException or FileNotFoundException: http://ws.audioscrobbler.com/2.0/ on my Nexus 4 running Android 4.2.2. Anybody can…
jul
  • 36,404
  • 64
  • 191
  • 318
1
vote
2 answers

Send object over udp in Java

I'm trying to send and object over udp by first serializing it and then deserializing it on the other end. I thought this would be trivial since I have sent other data over udp before and serialized stuff to the files etc. I have debugged thing…
Tumetsu
  • 1,661
  • 2
  • 17
  • 29
1
vote
2 answers

java - IO on internal class

Is it possible to ObjectOutputStream/ObjectInputStream an internal class? I can write it OK, and examine the created file, but when I try to read it back in using ObjectInputStream, I get an EOFException just trying to read an Object o =…
cvsdave
  • 1,576
  • 2
  • 12
  • 18
1
vote
1 answer

org.eclipse.jetty.io.EofException at Build and deploy

I'm trying to develop the samples but sometimes when I build and deploy an apps the process fails, and at eclipse Worklight Console appears: 14-feb-2013 16:28:55 com.worklight.report.impl.GadgetReportsServiceImpl loadProperties INFO: FWLSE3005I:…
user2064050
1
vote
2 answers

How can EOFException be thrown when only SQLException is allowed?

Is it supposedly possible for java.sql.Statement.execute to throw java.io.EOFException? In http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#execute%28java.lang.String,%20int%29 it is said that it may throw only java.sql.SQLException.…
Jānis Elmeris
  • 1,975
  • 1
  • 25
  • 43
1
vote
3 answers

How do I wait for data in file becomes available instead of getting EOFException

I'm displaying streaming content using a file to buffer it (because it could be large enough to keep it in RAM). I have two threads: the first downloads a file from server and writes it to the local storage, and the second reads that file and…
Grishka
  • 2,465
  • 1
  • 20
  • 38
1
vote
3 answers

EOFException using random access files

I'm using random access files to write a raf using an arrayList store. I do not know if it can be done, but I'm giving it a try because it is the best solution for me to create this application. Here is the run-time error that I am…
Pendo826
  • 1,002
  • 18
  • 47