java - Issue with Deserialization -


i have method in program reads file, , have associated both fileinputstream variable , objectinputstream variable. however, not know how many objects serialized in file when run program, not know how many objects deserialize using method readobject(). method project:

public void importresults(file file) throws filenotfoundexception, ioexception, classnotfoundexception {     testentry entry = null;     try(fileinputstream fis = new fileinputstream(file)) {         objectinputstream ois = new objectinputstream(fis);          tests.clear();          entry = (testentry)ois.readobject();          tests.add(entry);          ois.close();     } } 

the variable entry store testentry objects deserialize file. problem is, if try deserialize many objects, eofexception. how program figure out how many objects there serialized in file can deserialized right amount? appreciated! thank you.

just read in loop until eofexception, thrown when there no more objects read.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -