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
Create just one Scanner
, and reuse it each time. The problem is happening because the BufferedReader
*buffers* your input -- which means that it reads more than it needs and stores it up for later. When you create your second scanner, all the input has already been grabbed by the first
BufferedReader`, leaving nothing left to scan.