public void write ( byte [ ] buf , int offset , int len ) throws IOException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { // 306998.15 Tr . debug ( tc , "write len --> " + len + ", limit->" + limit ) ; } if ( len < 0 ) { if ( tc . isErrorEnabled ( ) ) Tr . error ( tc , "Illegal.Argument.Trying.to.write.chars" ) ; throw new IllegalArgumentException ( ) ; } if ( ! _hasWritten && obs != null ) { _hasWritten = true ; obs . alertFirstWrite ( ) ; } if ( limit > - 1 ) { if ( total + len > limit ) { len = limit - total ; except = new WriteBeyondContentLengthException ( ) ; } } int toWrite = 0 , amountWritten = 0 , remaining = 0 ; while ( amountWritten != len ) { checkList ( ) ; toWrite = len - amountWritten ; remaining = current . remaining ( ) ; if ( toWrite <= remaining ) { /* * We can write it all in the current buffer */ current . put ( buf , offset + amountWritten , toWrite ) ; amountWritten += toWrite ; } else { /* * Write what we can to the current position */ current . put ( buf , offset + amountWritten , remaining ) ; amountWritten += remaining ; } } count += len ; total += len ; check ( ) ; }
Writes a byte array