Assign standard in and out to InputStream and OutputStream - Java File Path IO

Java examples for File Path IO:FileOutputStream

Description

Assign standard in and out to InputStream and OutputStream

Demo Code

     //from w  w w.  j a va 2 s  . c  o  m

import java.io.*;

public class Main {
     public static void main(String[] args) {
           System.out.println("type:");
          InputStream in = System.in;
          OutputStream out = System.out;
          
          try {
               int input = in.read();
               System.out.println(input);
               out.write(input);
               out.close();
          } catch(IOException e) {
               e.printStackTrace();
          }
     }

}

Related Tutorials