Package java.nio

Examples of java.nio.CharBuffer.clear()


    // duplicate's position, mark, and limit should be independent to
    // buf
    duplicate.reset();
    assertEquals(duplicate.position(), originalPosition);
    duplicate.clear();
    assertEquals(buf.position(), buf.limit());
    buf.reset();
    assertEquals(buf.position(), originalPosition);

    // duplicate share the same content with buf
View Full Code Here


        } catch (NullPointerException e) {
            // expected
        }

    loadTestData2(other);
    other.clear();
    buf.clear();
    CharBuffer ret = buf.put(other);
    assertEquals(other.position(), other.capacity());
    assertEquals(buf.position(), buf.capacity());
    assertContentEquals(other, buf);
View Full Code Here

    cb.put("abc");
    cb2 = cb.duplicate();
    cb.append(cb);
    assertEquals(10, cb.position());
    cb.clear();
    cb2.clear();
    assertEquals(cb2, cb);

    cb.put("edfg");
    cb.clear();
    cb2 = cb.duplicate();
View Full Code Here

    cb.clear();
    cb2 = cb.duplicate();
    cb.append(cb);
    assertEquals(10, cb.position());
    cb.clear();
    cb2.clear();
    assertEquals(cb, cb2);
  }

  public void testAppendOverFlow() throws IOException {
    CharBuffer cb = CharBuffer.allocate(1);
View Full Code Here

                buffer = UTF8.encode(cs.toString());
            } else {
                buffer = byteBuffer;
                CharBuffer cbuffer = charBuffer;
                buffer.clear();
                cbuffer.clear();
                cbuffer.put(cs.toString());
                cbuffer.flip();
                encoder.encode(cbuffer, buffer, true);
                buffer.flip();
            }
View Full Code Here

            if (length > CHAR_THRESHOLD) {
                cbuffer = UTF8.decode(ByteBuffer.wrap(bytes, start, length));
            } else {
                cbuffer = charBuffer;
                ByteBuffer buffer = byteBuffer;
                cbuffer.clear();
                buffer.clear();
                buffer.put(bytes, start, length);
                buffer.flip();
                decoder.decode(buffer, cbuffer, true);
                cbuffer.flip();
View Full Code Here

      cbuf.position(0);
      enc.encode(cbuf, bbuf, true);
      if(bbuf.get(0) == '\\') {
        requiresEscapingEncoder = true;
      } else {
        cbuf.clear();
        bbuf.clear();
       
        cbuf.put("\u20a9");
        cbuf.position(0);
        enc.encode(cbuf, bbuf, true);
View Full Code Here

                read = r.read(cb.array(), cb.position(), cb.remaining());
            }
            cb.flip();
            invokeWebSocketProtocol(webSocket, cb.toString());
        } finally {
            cb.clear();
        }
    }

    private ByteBuffer resizeByteBuffer(WebSocket webSocket) throws IOException {
        int maxSize = byteBufferMaxSize;
View Full Code Here

    long total = 0;
    while (from.read(buf) != -1) {
      buf.flip();
      to.append(buf);
      total += buf.remaining();
      buf.clear();
    }
    return total;
  }

  /**
 
View Full Code Here

                c = s.charAt(i);
                if (c != '%')
                    break;
            }
            bb.flip();
            cb.clear();
            dec.reset();
            CoderResult cr = dec.decode(bb, cb, true);
            assert cr.isUnderflow();
            cr = dec.flush(cb);
            assert cr.isUnderflow();
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.