Since you indicated you absolutely must use the BufferedReader
, I believe one way to do this is to use the BufferedReader#readLine()
method instead. That will give you the full line as entered by the user, up to the line termination (either a '\r' or '\n' according to the documentation).
As Zong Zheng Li already said, while the Scanner
class can tokenize the input line for you, since you cannot use that, you'll have to do that yourself manually.
At this moment, one way that springs to mind is to simply split on a space (\s) character. So your code might look something like this:
System.out .print("Enter length, breadth and height->> (Press '0' to end the i/p)");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inputLine = br.readLine(); // get user input
String[] inputParts = inputLine.split("\\s+"); // split by spaces
int width = Integer.parseInt(inputParts[0]);
int height = Integer.parseInt(inputParts[1]);
int breadth = Integer.parseInt(inputParts[2]);
Note that I'm not showing any error or range checking, or input validation, as I'm just showing a general example.
I'm sure there's plenty of other ways to do this, but this is the first idea that popped in my mind. Hope it helps somewhat.