public long write ( final InputStream in ) throws IOException { if ( in == null ) throw new NullPointerException ( ) ; final long sizeStart = size ; while ( true ) { final int n = in . read ( buffer , pos , buffer . length - pos ) ; if ( n < 0 ) break ; pos += n ; size += n ; if ( pos == buffer . length ) flushBuffer ( ) ; } return ( size - sizeStart ) ; }
Writes all bytes available in the given inputstream to this buffer .