Im trying to do -
BufferedReader br = new BuffereReader(file);
Scanner s = new Scanner(br);
sys.out(s.next());
sys.out(buffReader.readLine());
What I expect to happen is to now have 2 separate readers on the file pointing at different places. However, the buffReader returns null on the readLine, while the scanner seems to work fine. Is it possible for me to have 2 readers like I want?
What I expect to happen is to now have 2 separate readers on the file pointing at different places.
Your expectation is misplaced. In the first place, both are connected to the same underlying file, which only has one current position. In the second place, the Scanner is wrapped around the BufferedReader, so any change in the position causes by the Scanner happens via the BufferedReader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With