Using Scanner class:
Scanner close methods:
next, nextByte, nextShort, nextInt, nextLong, nextFloat, nextDouble.
Which one should be opt?
It depends on the developer’s requirement.
For performance perspective, character by character reading from an unbuffered input stream or reader is inefficient. If the file needs to be read that way, developer should prefer BufferedReader.