Java Scanner with InputStream not working

后端 未结 2 2025
终归单人心
终归单人心 2021-01-28 22:51

I am reading an InputStream (fis) from a source and on which I have to do some multiple search. I am using Scanner class and I instantiate it after every search. But it works on

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 23:30

    The second print is returning zero.

    Because you've already read the stream to EOS counting lines the first time. So when you do it again there are zero lines left to count, so you get zero.

    Working as designed.

提交回复
热议问题