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

EOFException during readUTF in readfields method in Custom Key Writable class

This is my CustomWritable class where the eofexception is occurring during readUTF of name in readfields method. Can Anyone explain the problem and correct it import java.io.DataInput; import java.io.DataOutput; import…
Gowtham Kesa
  • 99
  • 2
  • 18
0
votes
1 answer

How to load records into a jTable from a file?

I'm making a GUI program, using netbeans, that is supposed to be an interface for managing records in a video store. This is the interface. It's two tabs, and one side allows a person to add records, whilst the other tab displays them. When a…
blue sky
  • 161
  • 1
  • 13
0
votes
2 answers

Java Exception in thread EOFException

I'm working on a data struct project and can't seem to find out why I am getting this exception. When I run my project in eclipse this is the error it gives. Exception in thread "main" java.io.EOFException at…
Mixed Pebble
  • 73
  • 1
  • 8
0
votes
1 answer

EOFException after readUTF randomly

I am developping an Android app and a java desktop app. The Android app send to the java desktop the sms received, and the desktop app provide an interface for answering to these sms. The android app is the server, the desktop app connects to it…
IronRabbit
  • 185
  • 1
  • 2
  • 13
0
votes
0 answers

Running from jar files gives EOFException

I am trying to create a simple messenger application between two computers, client to server. I have created the necessary port forwards. I have two programs - one for the server and one for the client - when I test them both on my machine from my…
0
votes
1 answer

EOFException in java networking

it is my first time using java networking. I have to use it for a project i am working on which is a simple card game. My server and client will communicate as the "Connection Received" does get printed. But after this line the following error…
Sean Powell
  • 564
  • 4
  • 20
0
votes
1 answer

EOFException from reading a file

The output is correct but it's followed by an EOFException. I read the documentation but still i don't know how to solve this try(ObjectInputStream ois = new ObjectInputStream(new FileInputStream("file.bin"))){ for(Ser s = (Ser)ois.readObject();…
T4l0n
  • 595
  • 1
  • 8
  • 25
0
votes
1 answer

java.io.EOFException when reading an object through ObjectInputStream

Wrote a simple piece of code top serialize standard employee object and deserialize it in the the same machine from different class. Both programs compiled and executed Obj output stream to create serialized object. Problem is with deserializing it.…
Abhi
  • 1,153
  • 1
  • 23
  • 38
0
votes
1 answer

Reading a flat buffer always gives a EOF Exception after last line

Here is the code i have for reading a flat buffer file. I always get a EOF exception . How do i get rid of that exception... File file = new File("/Users/samarnath/RmsOne/CreateFlatBuffer/src/com/rms/objects/SingleCoverRiskPolicy.fb"); …
user3897533
  • 417
  • 1
  • 8
  • 24
0
votes
2 answers

How to avoid EOFExeption by read from socket in AsyncTask that repeats in handle?

I need to update data from server every second. I create handle with AsyncTask, that repeats every second. This works, but about a minute it crushes with EOFException by reading from DataInputStream. Handler handler.postDelayed( new Runnable() { …
arcenciel4
  • 53
  • 7
0
votes
0 answers

eofexception on the server side of sslsocket while there is data for sure

I have this dummy program: package com.company; import javax.net.ssl.*; import java.io.*; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; import…
niceman
  • 2,653
  • 29
  • 57
0
votes
1 answer

Not in GZIP Format - JAVA

I'm trying to write compressed data to a file and then read in the data and decompress it using the GZIP library. I've tried changing all formatting to StandardCharsets.UTF-8 and ISO-8859-1 and neither have fixed the GZIP format error. I'm wondering…
Trey Taylor
  • 103
  • 2
  • 12
0
votes
1 answer

Getting an EOF exception while coverting bitmap to encoded string and then sending the encoded string using json object request

public void uploadImage(View v) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bp.compress((Bitmap.CompressFormat.JPEG), 100, stream); encodedString = Base64.encodeToString(stream.toByteArray(), …
Rohit Sharma
  • 83
  • 10
0
votes
1 answer

how to handle the EOF Exception in my given code

try { FileInputStream fis = new FileInputStream(f); Log.d("Objects remaining; ", fis.available()+""); ObjectInputStream ois = new ObjectInputStream(fis); Log.d("Objects remaining; ", fis.available() + ""); …
0
votes
1 answer

Java Sockets - EOFException when trying to implement multi-threading

I think it's because when I multi-thread the client&server, the DataOutputStream and DataInputStream buffers I use get overwritten or something like that since the socket can only have 1 duplex connection. Here's what I have for now: Client Class in…
user83676
  • 339
  • 1
  • 9
  • 15