Console input in Java (understanding the mechanism)

Normally in Java you can type in the console by writing like this

InputStreamReader isr = new InputStreamReader(;
BufferedReader br = new BufferedReader(isr);
String someValue = br.readLine();

What is represents the member variable in in the System class. Objects for standard input and standard output are pre-generated and assigned to and System.out. Therefore, you can use methods such as System.out.println () without creating an input / output object (instance) with new. handles the raw bytes that are input. Japanese is not processed correctly either. On Windows, Japanese is Unicode inside Java, so it must be converted at the input and output. The * InputStreamReader class * does the conversion.

1st line,   InputStreamReader isr = new InputStreamReader(;

The object isr will do the Japanese conversion for you.

To read line by line

BufferedReader br = new BufferedReader(isr);

You need to connect to an object of class BufferedReader. Since this object has a buffer function, it can be read line by line.

String someValue = br.readLine();

br.readLine () will convert the input line into Japanese and return it. In this way, you can put a line of strings in the buf of the String class.

Recommended Posts

Console input in Java (understanding the mechanism)
Input to the Java console
Read standard input in Java
Access the network interface in Java
Guess the character code in Java
Very simple input reception in Java
Specify the java location in eclipse.ini
Unzip the zip file in Java
Parsing the COTOHA API in Java
Understanding equals and hashCode in Java
Call the super method in Java
Get the result of POST in Java
Java reference to understand in the figure
Try using the Stream API in Java
I tried the new era in Java
[Java] Use cryptography in the standard library
Organized memo in the head (Java --Array)
Receive joystick input in Java LW JFL
Try calling the CORBA service in Java 11+
What is the main method in Java?
How to get the date in java
The story of writing Java in Emacs
[Java] Display the bit string stored in the byte type variable on the console
Regarding the transient modifier and serialization in Java
[Java] Handling of JavaBeans in the method chain
About the confusion seen in startup Java servers
The story of making ordinary Othello in Java
About the idea of anonymous classes in Java
A story about the JDK in the Java 11 era
Partization in Java
Organized memo in the head (Java --Control syntax)
Measure the size of a folder in Java
Understanding the MVC framework with server-side Java 1/4 View
Changes in Java 11
Understanding the MVC framework with server-side Java 3/4 Controller
Feel the passage of time even in Java
Rock-paper-scissors in Java
[Java] Read the file in src / main / resources
Organized memo in the head (Java --Data type)
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Pi in Java
I can't remember the text file input / output in Java, so I summarized it.
Try using the COTOHA API parsing in Java
[Java] Something is displayed as "-0.0" in the output
Import files of the same hierarchy in Java
Understanding the MVC framework with server-side Java 2/4 Model
FizzBuzz in Java
Get the URL of the HTTP redirect destination in Java
[Java] How to omit the private constructor in Lombok
Simple plugin mechanism in Spring, also consider the order
Read the packet capture obtained by tcpdump in Java
How to input / output IBM mainframe files in Java?
Which is better, Kotlin or Java in the future?
A note for Initializing Fields in the Java tutorial
[Java] Get the file in the jar regardless of the environment
[Java] Get the file path in the folder with List
[Java] When writing the source ... A memorandum of understanding ①
Java classes and instances to understand in the figure
Try global hooking in Java using the JNativeHook library
Change the storage quality of JPEG images in Java