java - how to read objects continuously -


i have written objects .bin file, trying read them console,

try(objectinputstream ois = new objectinputstream(new fileinputstream("file.bin"))){     for(ser s = (ser)ois.readobject(); s = (ser)ois.readobject(); s!=null)         system.out.println(s); }catch (ioexception | classnotfoundexception e){     e.printstacktrace(); } 

gives me error on second line in increment of loop : type mismatch: cannot convert ser boolean, how can ?

you have loop clauses mismatched. it's

for(declarations; exit_check; increment) 

in pattern you're trying use, like

for(ser ser = null; (ser = (ser)ois.readobject()) != null; /*blank*/) {    //do } 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -