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 only first time. Is there a way to reset the Scanner object? I have no control over the stream.
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
fis, MIFConstants.ENCODING_UTF_8)));
int count = 0;
while (sc.hasNextLine()) {
count++;
sc.nextLine();
}
System.out.println(count);
sc = new Scanner(new BufferedReader(new InputStreamReader(fis,
MIFConstants.ENCODING_UTF_8)));
count = 0;
while (sc.hasNextLine()) {
count++;
sc.nextLine();
}
System.out.println(count);
The second print is returning zero. Any ideas about this?