0

I often keep making menu-driven programs for which the User requires to enter his choice many times.

That's why , I wanna know- What edge does a 'Scanner' object provides over a 'BufferedReader' object or vice-versa?

and **How to take mutliple inputs using a 'BufferedReader' object ?(without using loops)"

P.S.- I know can that characters(Parsed) in BufferedReader

user3253946
  • 13
  • 1
  • 5

1 Answers1

0

Read this article here

BufferedReader

  • A BufferedReader is a simple class meant to efficiently read from the underling stream
  • read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient
  • Efficiency is improved appreciably if a Reader is warped in a BufferedReader.
  • BufferedReader is synchronized, so read operations on a BufferedReader can safely be done from multiple threads

Scanner

  • Scanner can do all that a BufferedReader can do and at the same level of efficiency
  • Scanner can parse the underlying stream for primitive types and strings using regular expressions

I suggest to use BufferedReader because it throws the exception immediately