java - Object Serialization/Deserialization and FileInputStream.available() -


i thinking way around whole bad habit using infinite loop read in objects. algorithm involves iteratively checking

if (fileinputstream("myfile.ser").available() != 0) , deserialize next object. otherwise, close file.

i want know if correct way go this.

i have read question's answers: may fileinputstream.available foolish me? , don't know if, empty, mean read pointer @ end-of-file.

in other words, could trust fileinputstream.available() to check how data still available reading file?

no, should never use inputstream.available() anything. method loosely defined (and implemented) mean anything.

why infinite loop "bad habit"?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -