T
T
Timofey Lanevich2016-06-06 16:49:45
Java
Timofey Lanevich, 2016-06-06 16:49:45

Your opinion. What is the best input method?

I am learning to write in Java. I enter data from the keyboard using Scanner, today my classmate said that he uses some kind of "buffer", and said that he seems to be the best.
And then it became interesting to me, which input method is the best in your opinion, what do you use?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Roo, 2016-06-06
@Timak31

Answer: none.
In Java, console input is almost never used and is offered for study only for educational purposes.
About the buffer:
It looks like this

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();

I like this option (with a buffer) more: for input from a file, the difference will be small (for text):
BufferedReader reader = new BufferedReader(new FileReader("input.txt"));
String s = reader.readLine();

Here you can read the discussion, on the topic "Which is better?" javatalks.ru/topics/25752

R
Rou1997, 2016-06-06
@Rou1997

The best one is the one that is better suited for this task, a classmate tells you nonsense, usually it doesn’t matter at all, so I use the one that comes to hand.

A
anton achehe, 2016-06-07
@mr-achehe

Use bufferedreader to come in handy later

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question