string - Reading multiple lines in java using a StringTokenizer -


I find myself trying to read several lines from a txt file in Java and I do not know how to do it Read the next line I tried loop for a while and when I ran my program, nothing came of it. I did while (line! = NULL) { so it can read the next line, but I have had no luck to complete the work.

How it reads text file

  20141003 20131105 19990205 20080304,20080305,20080306 19,990,206, hello, 20l4l00l,200003 20,050,505 July November August 19,640,503 19,980,707 19,642,199 20,141,013 < / Code> 
  import java.util. *; Public class token 1 {public static TextFileInput myFile; Public stable stringtooconizer myTokens; Public stable string [] list; Public stable string line; Public static zero main (string [] args) {myFile = new TextFileInput ("project1.txt"); Line = myFile.readLine (); MyTokens = new string locator (line, ","); List = new string [myTokens.countTokens ()]; Int i = 0; While (myTokens.hasMoreTokens ()) {list [i] = myTokens.nextToken (); I ++; The} (int j = 0; j & lt; list.length; j ++) system.out.println (list [j]); }}  

You can along the line read in a while loop Are there. The following is a very specific example implementation that reads each line of a file until EOF . I'm not sure why the implementation of your loop is not working, so posting your code.

  while ((line = reader.readline ()) = null {MyTokens = new Stringtoknaijhr (line, ","); list = new string [myTokens.countTokens ()]; Int i = 0; while (myTokens.hasMoreTokens ()) {list [i] = myTokens.nextToken (); i ++;}}  

and I will have to use the second assumption < Code> Partition () .


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -