Example usage for org.apache.commons.httpclient HttpConnection write

List of usage examples for org.apache.commons.httpclient HttpConnection write

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpConnection write.

Prototype

public void write(byte[] data) throws IOException, IllegalStateException 

Source Link

Document

Writes the specified bytes to the output stream.

Usage

From source file:org.woodwardbernsteinprotocol.protocol.DirectTransfer.java

@Override
public void transmit(Tip tip) throws IOException {
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    Base64OutputStream stream = new Base64OutputStream(data);
    tip.transmit(stream);/*from w ww.j av a  2 s  .  co m*/
    InputStream writer = new ByteArrayInputStream(data.toByteArray());
    HttpConnection client = new HttpConnection(config);
    client.open();
    byte[] buffer = new byte[10240];
    int read = 0;
    byte[] start = new byte[] { 't', 'i', 'p', '=' };
    client.write(start);
    while ((read = writer.read(buffer, 0, 10240)) > 0) {
        client.write(buffer, 0, read);
    }
    client.close();
}