java - how does BufferedReader keep track of what line has been read? -
I am reading a line from a file, and I believe that once I have read all the lines, I get an exception Is due to my loop position
Exception in thread "main" on java.lang.NullPointerException liarliar.main (liarliar.java:79)
... code ...
// Read the first line of the file iNumMembers = Integer.parseInt (br.readLine () .tim ()); // When reading the file ((sLine = br.readline (). Trim ()) = null) {// name and value remove 'm' string [] split = sLine.split ("\\ s +"); SAccuser = Partition [0]; Im = integer Pirice (split [1]); SaTheAccused = New String [IM]; (Saixide [i] = breadline (). Trim ();} // create member // initial name and the start of the number of subscribers member subscribers (for int i = 0; ii lt; im; i ++) = New member (); member.setName (sAccuser); member.setM (IM); member.setAccused (saTheAccused); veteranMembers.add (member);}
inside the loop Many lines have to be read so that the last line of the file can be read, then when readLine ()
and
Thanks.
readLine ()
returns empty space on EOF, and you are trying to call trim ()
on a redundant reference in the call < Inside the code> trim () loop, as
is the read file while ((sLine = br.readline ()) = null {// name And split the value 'M' string [] = sLine.trim (). Split ("\\ s +");
Comments
Post a Comment