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

Getting an EOFException in AsynTask (Android Studio)

So I'm getting an EOFException with this message: java.io.EOFException: \n not found: size=1 content=0d... And the code or line where the Exception occures: while ((line = reader.readLine()) != null) { stringBuilder.append(line); }
user13078077
0
votes
2 answers

EOFException when readObject in an android app

I use serialization to save data in my android app. Everything works beautifully until a user report he can not open his file. After examined the file he sent to me, it turned out the problem is an EOFException when readObject(). I opened the…
Ben Lee
  • 3,418
  • 1
  • 18
  • 19
0
votes
0 answers

Sending an EOF to exit out of a multi line read causes an exception when seeking input for another variable

If I have the following Python code: keyphrase = sys.stdin.read() print(keyphrase) domain = input() print(domain) I run it as follows: /Users/me/bin/python /Users/me/PycharmProjects/pem_formatter/test_code.py Please enter a key: Key line 1 Key line…
runnerpaul
  • 5,942
  • 8
  • 49
  • 118
0
votes
1 answer

Can I close my socket on the client-side without causing EOFException on server side?

I have just started working with sockets and I am not a very experienced programmer. I would like to close the connection on client side by the use of a disconnect button. The disconnect button would execute the following code: private void…
Papbad
  • 163
  • 2
  • 13
0
votes
0 answers

java.io.EOFException: \n not found: size=0 content=…

I am getting following exception in API request. I have tried solutions mentioned in this website and on OkHttp Github page but still this issue is not fixed. HTTP FAILED: java.io.IOException: unexpected end of stream on…
Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103
0
votes
0 answers

Using filepath for FileInputStream throws java.io.EOFException

I'm trying to import a file into my class via FileInputStream, but it throws the error java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) at…
ElliottV4
  • 51
  • 7
0
votes
1 answer

How to soleve 'java.io.EOFException: Unexpected end of ZLIB input stream' while use ImageIO.read()

the png I can open the png but used code to read it failed. The exception is 'java.io.EOFException: Unexpected end of ZLIB input stream' and the line is 4 where use ImageIO.read() function. I succeded reading other png by using the same…
0
votes
1 answer

How to catch broken pipe for sockets?

I have written a Java client-server application using Sockets. I'm using the method writeUnshared() ofObjectOutputStream and readObject() of ObjectInputStream. Now I would like to detect when the connection is broken to reconnnect (e.g. when Wifi…
machinery
  • 5,972
  • 12
  • 67
  • 118
0
votes
1 answer

Jenkins : Exception in thread "main" java.io.EOFException while trying to trigger child job

I am trying to execute following command : java -jar /jenkins-cli.jar -s http://example.com:8080/jenkins build childJob However, I get following error : java.io.EOFException at java.io.DataInputStream.readBoolean(DataInputStream.java:244) …
AnswerDroid
  • 1,873
  • 2
  • 33
  • 52
0
votes
2 answers

java.io.EOFException being thrown

This code is throwing an java.io.EOFException, and I am not sure why this is happening. import java.io.*; class ReadInts { public static void main(String[] args) { String fileName = "intData.dat"; int sum = 0; try { …
user1166232
0
votes
0 answers

Why am I Getting a BindException along with EOFException?

So I'm creating a chat room, and the idea is that the servers and clients are multithreaded. So when a client sends a message, it goes to the server, the server puts that into a file with the rest of the chat log, and then every little while a…
Jackson
  • 7
  • 1
0
votes
1 answer

JAVA what causes end of stream on network sockets?

From what I understand the whole point of end of stream is to tell the input stream when to stop reading data, which makes sense in file streams, but when it's an ObjectInputStream why would I want it to stop reading objects if I might send another…
0
votes
0 answers

java.io.EOFException when using spark-submit with yarn as master on a cluster

I'm trying to run a jar file with this spark-submit command: spark-submit --master yarn --deploy-mode cluster --executor-memory 3g --class my.package.Main my-jar-file.jar The class Main is the jar's main class, and here's the contents (all in…
user4803846
0
votes
1 answer

Socket System EOFException (ObjectInputStream)

Hey i'm coding a socket system with a open src library... and everytime when i'm sending a message or something i get an EOFException public Datapackage sendMessage(Datapackage message, int timeout) { try { Socket tempSocket; if…
0
votes
2 answers

End of File Exception on ObjectInputStream.readObject

My application streams twitter data and writes them to files. while(true){ Status status = queue.poll(); if (status == null) { Thread.sleep(100); } if(status!=null){ list.add(status); …
sirdan
  • 1,018
  • 2
  • 13
  • 34