java - My program keeps throwing IO exception after reading from binary file -


I have taken a text file and typed the object into a binary file and converted it into binary, then I Trying to read from the binary file, which works perfectly till the last record and then it throws the IO exception and never goes on my previous print statement.

Below is my code that is triggering error

  Try {Object InputStream objinputStream2 = New ObjectInststream (New file InputStream ("BinaryFile")); For (int run = 0; run  

Any help is appreciated

Stack trace:

  at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:606) bluej.runtime.ExecServer $ 3.run (ExecServer.java:730)  
< / Div>

You will need to reconsider the status of the loop: for (int run = 0; run .

Neither run and count has been modified inside the loop, so it will run forever (unless you have a record from your file and exception occurs ).

I think that something like this should be:

  int count = 0; For (int run = 0; run  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -