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
Post a Comment