Here is what I am trying to read :
FileInputStream fis=new FileInputStream("count.txt");
BufferedInputStream bis=new BufferedInputStream(fis);
DataInputStream dis=new DataInputStream(bis);
while(dis.read()!=-1)
{
orderCount=dis.readInt();
newOrderCount=dis.readInt();
}
Count.txt has data such as 0 0 0 0 0 0 0 1, but for some reason i get an EOF exception,please help!
EOFException
means you tried to read past the end of the stream, which probably happened because you are reading a byte and then throwing it away, which is already a bug, as it puts you out of sync with the sender. Change the loop test to while (true)
, catch EOFException
, and, when you get it, close the socket and break out of the loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.