import java.io.InputStreamReader; import java.io.IOException; public class InputStreamReaderDemo { public static void main(String[] args) { /* The InputStreamReader uses the InputStream (System.in) to read 8-bit bytes. It then assembles the bytes into 16-bit chars. */ InputStreamReader reader = new InputStreamReader(System.in); try { int i; while ((i = reader.read()) != -1) { //i is in the range 0 to 65535 inclusive. System.out.print(i); final char c = (char)i; if (!Character.isISOControl(c)) { System.out.print(" " + c); } System.out.println(); } } catch (IOException e) { System.err.println(e.getMessage()); } } }