drools-eclipse/org.guvnor.eclipse.webdav/src/client/org/eclipse/webdav/http/client/Message.java
public void write(OutputStream os) throws IOException {
        Assert.isTrue(!inputRead);
        Assert.isTrue(!hasInputStream);

        int bytesRead = 0;
        int totalBytesRead = 0;
        byte[] buffer = bufferPool.getBuffer();
        long contentLength = getContentLength();

        try {
            while (bytesRead != -1 && (contentLength == -1 || contentLength > totalBytesRead)) {
                if (contentLength == -1) {
                    bytesRead = is.read(buffer);
                } else {
                    bytesRead = is.read(buffer, 0, (int) Math.min(buffer.length, contentLength - totalBytesRead));
                }
                if (bytesRead == -1) {
                    if (contentLength >= 0) {
                        throw new IOException(Policy.bind("exception.unexpectedEndStream")); //$NON-NLS-1$
                    }
                } else {
                    totalBytesRead += bytesRead;
                    os.write(buffer, 0, bytesRead);
                }
            }
        } finally {
            bufferPool.putBuffer(buffer);
            inputRead = true;
        }
    }
public void write(OutputStream os) throws IOException {
        Assert.isTrue(!inputRead);
        Assert.isTrue(!hasInputStream);

        int bytesRead = 0;
        int totalBytesRead = 0;
        byte[] buffer = bufferPool.getBuffer();
        long contentLength = getContentLength();

        try {
            while (bytesRead != -1 && (contentLength == -1 || contentLength > totalBytesRead)) {
                if (contentLength == -1) {
                    bytesRead = is.read(buffer);
                } else {
                    bytesRead = is.read(buffer, 0, (int) Math.min(buffer.length, contentLength - totalBytesRead));
                }
                if (bytesRead == -1) {
                    if (contentLength >= 0) {
                        throw new IOException(Policy.bind("exception.unexpectedEndStream")); //$NON-NLS-1$
                    }
                } else {
                    totalBytesRead += bytesRead;
                    os.write(buffer, 0, bytesRead);
                }
            }
        } finally {
            bufferPool.putBuffer(buffer);
            inputRead = true;
        }
    }
public void write ( OutputStream os ) throws IOException { Assert . isTrue ( ! inputRead ) ; Assert . isTrue ( ! hasInputStream ) ; int bytesRead = 0 ; int totalBytesRead = 0 ; byte [ ] buffer = bufferPool . getBuffer ( ) ; long contentLength = getContentLength ( ) ; try { while ( bytesRead != - 1 && ( contentLength == - 1 || contentLength > totalBytesRead ) ) { if ( contentLength == - 1 ) { bytesRead = is . read ( buffer ) ; } else { bytesRead = is . read ( buffer , 0 , ( int ) Math . min ( buffer . length , contentLength - totalBytesRead ) ) ; } if ( bytesRead == - 1 ) { if ( contentLength >= 0 ) { throw new IOException ( Policy . bind ( "exception.unexpectedEndStream" ) ) ; //$NON-NLS-1$ } } else { totalBytesRead += bytesRead ; os . write ( buffer , 0 , bytesRead ) ; } } } finally { bufferPool . putBuffer ( buffer ) ; inputRead = true ; } }
Writes this messages body to the given output stream. This method may
only be called once during the lifetime of this message.

@param os an output stream
@exception IOException if there is an I/O error
Writes this messages body to the given output stream . This method may only be called once during the lifetime of this message .