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

Java Program throws java.io.EOFException just after starting the jar

I have a jar which takes data from sql (in a loop) and puts into queue after processing it. It has been running well & good until today before started throwing Communications link failure due to underlying exception:. & the following continued . .…
Shashank
  • 297
  • 3
  • 13
0
votes
2 answers

Java EOFException While Reading Object From A Server (not a file)

So, I write an object to a client like so: ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream()); out.writeObject(args); out.close(); And receive the object on the client side like so: ObjectInputStream in = new…
LAB
  • 85
  • 1
  • 1
  • 6
0
votes
2 answers

EOFException in objectinputstream readobject

i want to make a server client application. i set everything up and i get this error. i want the app to wait till i get more data. java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source) at…
TheGathron
  • 53
  • 1
  • 3
  • 12
0
votes
3 answers

java.io.eofexception when downloading files from remote server to android phone

My objective is to download 200 .jpg files that are in a remote server to my android phone (running jellybeans). In order to do that I'm running below method in a loop with different file names assigned to the filename parameter. It runs well untill…
Asanga Dewaguru
  • 1,058
  • 2
  • 16
  • 31
0
votes
1 answer

EOFException / SocketException when working with sockets and threads

This socket application works perfectly fine until I add support for multiple client connections to the server. Then I get a EOFException from the client, and a SocketException: Socket closed from the server. Server.java: public class Server { …
asmb
  • 1,015
  • 2
  • 8
  • 11
0
votes
0 answers

EOFException occured when send many objects over socket

I am making a program that uses socket to connect to others. When I send String or array of String it works fine. But when I try to send Objects over socket it doesnt work and EOFException appeared. I tried to find out by my own but its seem too…
0
votes
1 answer

EOFException when dealing with readObject

I am trying to de-serialize an object from a file, but when I do I get the following stack trace: 21.04 10:33:18 [Server] WARN at java.lang.Thread.run(Unknown Source) 21.04 10:33:18 [Server] WARN at…
user2426902
0
votes
2 answers

Inputstream readUTF can't read UTF

I am a total noob at Java, so apologies if this is a rookie mistake. I was trying out Java NIO, I still haven't gotten to a stage where I am using the non-blocking feature. I just am not able to get the server to read a string, I understand its not…
Desert Ice
  • 4,461
  • 5
  • 31
  • 58
0
votes
1 answer

EOFException Runtime Error while dealing with SealedObject

I am currently experimenting with the encryption and decryption of objects but I am stumbling upon an EOFException every time my read method is declared. I feel like there is a lot of redundancy within my code trying to deal with all of the…
coder18
  • 13
  • 3
0
votes
2 answers

EOFException in a Java client-server app

I'm developing a simple client-server clock, which transmits the current time to all clients, hosted by the clock server application. There is a timed event (TimerTask) that sends the data periodically to all clients. And at the Server part it works…
user4359659
  • 149
  • 2
  • 4
  • 18
0
votes
1 answer

eofExeption with objectstream and hashmap

so i have a problem with storing or loading a hashmap from an objectstream. The file is saved and i can see that it store some kind of information. the problem is when i try to read the hashmap it gives me an EOF error. thanks in advance for your…
0
votes
2 answers

EOFException in ObjectInputStream Only happens with Webstart not by java(w).exe?

Anyone familiar with the differences in starting with Webstart(javaws.exe) compared to starting the app. using java.exe or javaw.exe regarding streams ? This is the exception which i ONLY get when using Webstart : java.io.EOFException at…
Houtman
  • 2,819
  • 2
  • 24
  • 34
0
votes
1 answer

How to send files over https using Apache HttpClient Library?

I've recently installed an ssl certificate on my server and switched the url in the client program to use the https version of the url. Now, for some reason, when sending files to the server, the parameters sent on the multipart request aren't on…
0
votes
1 answer

java.io.EOFException when reading from DataInputStream using the readUTF() method

I am making a Messenger program which uses client socket and server socket but I keep running into a problem when the DataInputStream.readUTF() method is run. I get a java.io.EOFException. sorry about my poor programming and terribly named…
user287184
  • 23
  • 1
  • 4
0
votes
1 answer

EOF Exception in a thread using sockets

I have the code below: while (true) { lengthInput = instr.readByte(); // Other code } The thing is that I'm using a client to send information to the socket, but after it finishes I got EOF Exception and it brokes the thread, what I need is to…
zepol
  • 187
  • 5
  • 20