DEV Community

Discussion on: Scanner Vs BufferedReader

Collapse
 
mikevv profile image
MikeVV
  • Scanner is a reader for some kind of typed objects like numbers, string, etc and with Scanner you can read data directly to variable of the type you need

    int age = new Scanner(System.in).nextInt();

  • BufferedReader is just a reader object with internal data buffer. It is used here as an alternative as plain reader does not have "readLine" method and as a result cannot read from user input till the end of line without a lot of additional code.

In my practice I have seen Scanner used only for user input, but BufferedReader is more widely used, actually for every 1st file reading/stream reading as without buffer file/stream java is reading data slowly byte by byte or something like this.