I cannot understand how System.in.read() method works.
There is such a code:
public static void main(String[] args) throws IOException {
while (true){
Integer x = System.in.read();
System.out.println(Integer.toString(x, 2));
}
I know that System.in.read() method reads from the inputstream PER ONE BYTE.
So when I enter 'A'(U+0041, one byte is used to store the char) - the program output is:
1000001 (U+0041)
1010 (NL) - it works as expected.
But when I enter 'Я'(U+042F, two bytes are used to store the char) - the output is:
11010000 (byte1)
10101111 (byte2)
1010 (byte3 - NL)
The real code for letter 'Я'(U+042F) is 10000101111.
Why 11010000 10101111 (byte1 + byte2) is not the binary code for letter 'Я'(U+042F)?