using scanner to read file but skip blank lines into a 2d array

前端 未结 2 1913
日久生厌
日久生厌 2021-01-28 04:01

I am struggling to use scanner class to read in a text file while skipping the blank lines.

Any suggestions?

   Scanner sc = new Scanner(new BufferedRead         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-28 04:50

    Try adding this to your code:

    sc.skip("(\r\n)");
    

    It will ignore blank lines. For More information: Scanner.skip()

提交回复
热议问题