FileDocCategorySizeDatePackage
BufferedStreamCopier.javaAPI DocExample868Sun Mar 28 19:06:10 BST 1999com.macfaq.io

BufferedStreamCopier

public class BufferedStreamCopier extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidcopy(java.io.InputStream in, java.io.OutputStream out)


    // do not allow other threads to read from the
    // input or write to the output while copying is
    // taking place
    
    synchronized (in) {
      synchronized (out) {
        BufferedInputStream bin = new BufferedInputStream(in);
        BufferedOutputStream bout = new BufferedOutputStream(out);
  
        while (true) {
          int datum = bin.read();
          if (datum == -1) break;
          bout.write(datum);
        }
  
        bout.flush();

      }
    }
  
public static voidmain(java.lang.String[] args)


    try {
      copy(System.in, System.out);
    }
    catch (IOException e) {
      System.err.println(e);
    }