Reading a specific line from a text file in Java

后端 未结 9 767
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 07:34

Is there any method to read a specific line from a text file ? In the API or Apache Commons. Something like :

String readLine(File file, int lineNumber)
         


        
9条回答
  •  臣服心动
    2020-11-27 07:58

    Using File Utils:

    File fileFeatures = new File(
                    "Homework1AdditionalFiles/jEdit4.3/jEdit4.3ListOfFeatureIDs.txt");
    String line = (String) FileUtils.readLines(fileFeatures).get(lineNumber);
    

提交回复
热议问题