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
2
votes
1 answer

java.io.EOFException (having problems with closing streams)

Got a simple client/server app only with login/logout implemented. When i press connect it runs perfect, but the problem comes after when trying to disconnect (getting EOFException on client side). Im almost sure its due to a poor close of the…
Nadven
  • 21
  • 1
  • 2
2
votes
0 answers

SocketException and EOFException while connecting to web server using HttpsUrlConnection in Android

My clients get sometimes two exceptions SocketException: Socket is closed and EOFException when I try to connect with the soap web server. I use this code: private String callWebService(String soapAction, String envelope, boolean runInBackground) { …
Bartosz Bialecki
  • 4,391
  • 10
  • 42
  • 64
2
votes
4 answers

Getting java.io.EOFException using HttpUrlConnection

I am getting EOFException when I call a REST API. I know it says that response is null. But it should not. I use same API in an iOS application without any problem. Here is my code : try { url = new URL(baseUrl); } // Thrown when URL could…
Geek
  • 8,280
  • 17
  • 73
  • 137
2
votes
7 answers

Reading Objects until End of File in java

I'm trying to write a program where the user can: 1) Add a person to the contact (name, phone, email), 2) Remove a person from the contacts, 3) Read all from contact. The Way I'm doing this is I'm asking for the user for their choice and…
askaka12
  • 195
  • 2
  • 2
  • 9
1
vote
2 answers

Why do I get the java.io.EOFException and the ArrayOutOfBounds error? Help?

I am trying to create a sort of simple GUI where im trying to save a couple of Strings and doubles and one int, im using the basic property of OOP which is inheritance I created a class Autos which is essentially the super Class. The problem seem to…
user1079801
  • 31
  • 1
  • 6
1
vote
2 answers

EOFException in Java Android? Help needed

I am trying to do some kind of serialization where I can directly read and write objects from file. To start of I just tried to write a character to file and tried to read it. This keeps giving me EOF exception always. I am trying it on a Android…
Vinod
  • 31,933
  • 35
  • 96
  • 119
1
vote
1 answer

Getting "java.io.EOFException" after sending a file throught socket

I'm trying to implement basic communication through sockets, what I have now is: server start's to listen on socket, this.serverSocket_ = new ServerSocket(this.serverPort_); clientSocket = this.serverSocket_.accept(); client connects, and server…
WojtusJ
  • 1,318
  • 1
  • 12
  • 19
1
vote
3 answers

MySQL Communications link failure due to underlying exception

I am facing such annoying problem, running on Tomcat 6 and MySQL using TomcatJDBC Lib. com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION **…
BShip
  • 23
  • 1
  • 2
  • 3
1
vote
2 answers

Gzip decompress throws EOFException

I am currently trying to decompress a byte array by using gzip decompress, however, I receive an EOFException, can anyone help me with this error ? Thanks this is my codes: import java.io.ByteArrayInputStream; import…
1
vote
3 answers

java client server serialization problem

hi i am working on a client server programme with containing some special functions like sending private message, show online list etc. so i know i must use serialization and first i managed it but after a while a screwed up :) nowadays i spending…
quartaela
  • 2,579
  • 16
  • 63
  • 99
1
vote
1 answer

java.io.EOFException at org.apache.tomcat.util.net.NioEndpoint (tomcat 9 & openjdk 8)

I am upgrading the tomcat and openjdk version for a project. Target: Tomcat 9.0.63 and openjdk-8u322-b06. However, getting EOFException when using Tomcat 9.0.63 and openjdk-8u322-b06. I don't know how to fix it. Findings: Error occurs if using…
MLM
  • 11
  • 1
  • 4
1
vote
0 answers

HTTP request failing occasional with EOFException in Java

I am doing a POST call in Java to an external device. Sometimes, and only sometimes it fails with EOFException. I increased the timeout value however it keeps thorwing the EOFException. Any idea what could cause that? Error processing POST 2 request…
Chris
  • 93
  • 8
1
vote
2 answers

Receive EOFException after the first SocketTimeoutException

This is a simple TCP Server (echo) and TCP Client in Java. If I comment the following line, the program is working: st.setSoTimeout(WAITING_FOR_INPUT); But if I use this socket timeout method, then I will get first an InterruptedIOException (it's…
1
vote
1 answer

Java - IzPack and EOFException

I have one installer with several packs. None is required. When I mark all, the installation completes with success. When I mark just two packs, I get EOFException. Edit Using trace I can see the stacktrace: Current focus owner:…
user800014
1
vote
2 answers

EOFException when sending data from Applet to a servlet

I am trying to get simple user Details (Name,Phone No, Gender(Option Box)) in an Applet and display the details in an JSP.I put all the three details in an HashMap and send it in a output Stream. The Applet Code is as Follows. try { …
anthoon
  • 101
  • 9