Java - Parsing Text File

前端 未结 2 538
孤街浪徒
孤街浪徒 2020-12-19 16:10

I have an input text file in this format:

 :   ...
 :   ...
...
2条回答
  •  忘掉有多难
    2020-12-19 16:25

    The firstly you have to read line from file and after this split read line, so your code should be like:

    FileInputStream fstream = new FileInputStream("your file name");
    // or using Scaner
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    //Read File Line By Line
    while ((strLine = br.readLine()) != null)   {
      // split string and call your function
    }
    

提交回复
热议问题