Java InputStream copy to OutputStream

Description

Java InputStream copy to OutputStream

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
   public static void main(String args[]) throws IOException {
      InputStream in = new FileInputStream("Main.java");
      OutputStream out = new FileOutputStream("Main1.java");
      int b;/*  ww  w  .  j  av a2 s  .  com*/
      while ((b = in.read()) != -1)
         out.write(b);
      in.close();
      out.close();
   }
}



PreviousNext

Related