Java - Read from console using InputStreamReader and output with OutputStreamWriter

Description

Read from console using InputStreamReader and output with OutputStreamWriter

Demo

import java.io.*;

public class Main {
     public static void main(String[] args) {
           System.out.println("type:");
          InputStreamReader in = new InputStreamReader(System.in);
          OutputStreamWriter out = new OutputStreamWriter(System.out);
          /*w  ww  . j  a  v a  2  s . com*/
          try {
               int input = in.read();
               System.out.println(input);
               out.write(input);
               out.close();
          } catch(IOException e) {
               e.printStackTrace();
          }
     }

}

Related Topic