Package org.apache.http.util

Examples of org.apache.http.util.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


        // 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();
    }

    /**
     * Creates start of a part
     *
 
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

   
    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

       
        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

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.