Package org.apache.http.io

Examples of org.apache.http.io.ByteArrayBuffer.toByteArray()


       
        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
        buffer.append(b1, 0, b1.length);
        buffer.append(b2, 0, b2.length);
        
        assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
    }
   
    public void testAppendNullCharArray() throws Exception {
        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
        buffer.append((char[])null, 0, 0);
View Full Code Here


   
    public void testSimpleAppend() throws Exception {
      ByteArrayBuffer buffer = new ByteArrayBuffer(16);
      assertEquals(16, buffer.capacity());
      assertEquals(0, buffer.length());
      byte[] b1 = buffer.toByteArray();
      assertNotNull(b1);
      assertEquals(0, b1.length);
      assertTrue(buffer.isEmpty());
        assertFalse(buffer.isFull());
     
View Full Code Here

      assertEquals(16, buffer.capacity());
      assertEquals(4, buffer.length());
      assertFalse(buffer.isEmpty());
        assertFalse(buffer.isFull());
     
      byte[] b2 = buffer.toByteArray();
      assertNotNull(b2);
      assertEquals(4, b2.length);
      for (int i = 0; i < tmp.length; i++) {
          assertEquals(tmp[i], b2[i]);
          assertEquals(tmp[i], buffer.byteAt(i));
View Full Code Here

                buffer.append(tmp, 0, l);
            }
        } finally {
            instream.close();
        }
        return buffer.toByteArray();
    }
       
    public static String getContentCharSet(final HttpEntity entity) {
        if (entity == null) {
            throw new IllegalArgumentException("HTTP entity may not be null");
View Full Code Here

   
    public void testSimpleAppend() throws Exception {
      ByteArrayBuffer buffer = new ByteArrayBuffer(16);
      assertEquals(16, buffer.capacity());
      assertEquals(0, buffer.length());
      byte[] b1 = buffer.toByteArray();
      assertNotNull(b1);
      assertEquals(0, b1.length);
      assertTrue(buffer.isEmpty());
        assertFalse(buffer.isFull());
     
View Full Code Here

      assertEquals(16, buffer.capacity());
      assertEquals(4, buffer.length());
      assertFalse(buffer.isEmpty());
        assertFalse(buffer.isFull());
     
      byte[] b2 = buffer.toByteArray();
      assertNotNull(b2);
      assertEquals(4, b2.length);
      for (int i = 0; i < tmp.length; i++) {
          assertEquals(tmp[i], b2[i]);
          assertEquals(tmp[i], buffer.byteAt(i));
View Full Code Here

       
        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
        buffer.append(b1, 0, b1.length);
        buffer.append(b2, 0, b2.length);
        
        assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
    }
   
    public void testAppendNullCharArray() throws Exception {
        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
        buffer.append((char[])null, 0, 0);
View Full Code Here

                buffer.append(tmp, 0, l);
            }
        } finally {
            instream.close();
        }
        return buffer.toByteArray();
    }
       
    public static String getContentCharSet(final HttpEntity entity) {
        if (entity == null) {
            throw new IllegalArgumentException("HTTP entity may not be null");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.