java.lang.NumberFormatException: null When I try to read a number from a .txt -
try { bufferedreader in = new bufferedreader(new filereader("encuestas/encuesta_"+s+".txt")); try { this.id = integer.valueof(in.readline()); this.genero = in.readline(); this.fecha = in.readline(); this.n_preguntas = integer.valueof(in.readline()); for(int = 0; < this.n_preguntas; ++i){ integer tip = integer.valueof(in.readline()); string aux = ""; aux = in.readline();
when try read integer tip = integer.valueof(in.readline()); doesn't work , don't understand why... same before , working. error:
5. leer encuestajava.lang.numberformatexception: null @ java.lang.integer.parseint(integer.java:542) @ java.lang.integer.valueof(integer.java:766) @ prop.dominio.encuesta.leer(encuesta.java:134) @ prop.dominio.driver_encuesta.main(driver_encuesta.java:219)
simply check this,
for(int = 0; < this.n_preguntas; ++i){ string line = null; if((line = in.readline()) != null){ integer tip = integer.valueof(line); string aux = ""; }
if there ten lines in file, when reading 11th line got error
Comments
Post a Comment