Copy byte between BufferedInputStream and BufferedOutputStream : BufferedInputStream « File Input Output « Java






Copy byte between BufferedInputStream and BufferedOutputStream

  

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

class BufferedCopy {
  public static void main(String[] args) throws Exception {
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;

    FileInputStream fis = new FileInputStream(args[0]);
    bis = new BufferedInputStream(fis);

    FileOutputStream fos = new FileOutputStream(args[1]);
    bos = new BufferedOutputStream(fos);

    int byte_;
    while ((byte_ = bis.read()) != -1)
      bos.write(byte_);
  }
}

   
    
  








Related examples in the same category

1.Create BufferedInputStream from FileInputStream
2.Read from file with BufferedInputStream
3.Read File in String Using Java BufferedInputStream Example
4.Read File Using Java BufferedInputStream Example
5.Use buffered streams to copy a file
6.Import a file of exported preference data.
7.Fast BufferedInputStream