Code example for ByteArrayBuffer

Methods: appendtoByteArray

  //put body together and return it 
  public byte[] getContent() throws UnsupportedEncodingException 
    // create new byte array buffer and get start and end as byte arrays 
    ByteArrayBuffer endBuffer = new ByteArrayBuffer(0);
    byte[] start              = buffer.toByteArray();
    byte[] end                = (boundary+DASHES).getBytes(HTTP.DEFAULT_CONTENT_CHARSET);
    // append the start and end to new byte array buffer 
    endBuffer.append(start, 0, start.length);
    endBuffer.append(end, 0, end.length);
    // return buffer as content 
    return endBuffer.toByteArray();
  //create start of the body 
  private String createStart(String contentType)