I have made very simple code to larn the functionality.
String str = "ABC";
InputStream input = new ByteArrayInputStream(str.getBytes());
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
System.out.println(Character.valueOf((char) reader.read()));
System.out.println(reader.read());
System.out.println(reader.read());
System.out.print(reader.read());
Secondly this one,
String str = "ABC";
InputStream input = new ByteArrayInputStream(str.getBytes("UTF-8"));
System.out.print(input.read());
System.out.print(input.read());
}
output is same for the ways. Which way is good, and when should I use the each one of them? Thanks.