Ignore a line while reading a file in java

前端 未结 3 617
粉色の甜心
粉色の甜心 2021-01-27 00:42

I have some code to read the lines from a file, I would like to recognize when the line starts or the fisrt character (not blank) is \'*\' and ignore it, so inside

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-27 01:25

    input = new BufferedReader(new FileReader(new File(finaName)));
    String line = null;
    while ((line = input.readLine()) != null) {
      if(line.trim().indexOf('*') == 0)
        continue;
      String[] words = line.split(" "); 
        .... 
    }
    

提交回复
热议问题