Method to find string inside of the text file. Then getting the following lines up to a certain limit

前端 未结 7 562
孤街浪徒
孤街浪徒 2020-12-08 15:35

So this is what I have so far :

public String[] findStudentInfo(String studentNumber) {
                Student student = new Student();
                Scan         


        
7条回答
  •  执笔经年
    2020-12-08 16:13

    Here is the code of TextScanner

    public class TextScanner {
    
            private static void readFile(String fileName) {
                try {
                  File file = new File("/opt/pol/data22/ds_data118/0001/0025090290/2014/12/12/0029057983.ds");
                  Scanner scanner = new Scanner(file);
                  while (scanner.hasNext()) {
                    System.out.println(scanner.next());
                  }
                  scanner.close();
                } catch (FileNotFoundException e) {
                  e.printStackTrace();
                }
              }
    
              public static void main(String[] args) {
                if (args.length != 1) {
                  System.err.println("usage: java TextScanner1"
                    + "file location");
                  System.exit(0);
                }
                readFile(args[0]);
          }
    }
    

    It will print text with delimeters

提交回复
热议问题