public static OutputStream leftShift(OutputStream self,InputStream in) throws IOException {
  byte[] buf=new byte[1024];
  while (true) {
    int count=in.read(buf,0,buf.length);
    if (count == -1)     break;
    if (count == 0) {
      Thread.yield();
      continue;
    }
    self.write(buf,0,count);
  }
  self.flush();
  return self;
}

public static OutputStream leftShift ( OutputStream self , InputStream in ) throws IOException { byte [ ] buf = new byte [ 1024 ] ; while ( true ) { int count = in . read ( buf , 0 , buf . length ) ; if ( count == - 1 ) break ; if ( count == 0 ) { Thread . yield ( ) ; continue ; } self . write ( buf , 0 , count ) ; } self . flush ( ) ; return self ; }
pipe an inputstream into an outputstream for efficient stream copying .
