Package java.nio

Examples of java.nio.CharBuffer.limit()


        h.check(true);
      }
    h.check(slice.isDirect(), false);
    h.check(slice.isReadOnly(), true);
    h.check(slice.length(), 3);
    h.check(slice.limit(), 3);
    h.check(slice.position(), 0);

    // This shows a JDK bug..
    h.check(slice.get(), 'o');
    h.check(slice.get(), ' ');
View Full Code Here


  private void testDuplicate(TestHarness h)
  {
    StringBuilder b = new StringBuilder("Hello World");
    CharBuffer cb = CharBuffer.wrap(b);
    cb.position(4);
    cb.limit(7);
    CharBuffer dup = cb.duplicate();

    h.check(dup.capacity(), 11);
    try
      {
View Full Code Here

        h.check(true);
      }
    h.check(dup.isDirect(), false);
    h.check(dup.isReadOnly(), true);
    h.check(dup.length(), 3);
    h.check(dup.limit(), 7);
    h.check(dup.position(), 4);

    h.check(dup.get(), 'o');
    h.check(dup.get(), ' ');
    h.check(dup.get(), 'W');
View Full Code Here

                                      : m_byteBuffer;

                // Since ASCII is single-byte, retrict encoder character consumption
                // to at most 'len' characters' to produce at most len ASCII
                // characters
                int cbLimit     = cb.limit();
                int cbPosistion = cb.position();

                cb.limit(cbPosistion + len);
                bb.clear();
View Full Code Here

                // to at most 'len' characters' to produce at most len ASCII
                // characters
                int cbLimit     = cb.limit();
                int cbPosistion = cb.position();

                cb.limit(cbPosistion + len);
                bb.clear();

                int         bbPosition = bb.position();
                CoderResult result     = m_encoder.encode(cb, bb, false);
View Full Code Here

                CoderResult result     = m_encoder.encode(cb, bb, false);

                if (bbPosition == bb.position() && result.isUnderflow()) {

                    // surrogate character time
                    cb.limit(cb.limit() + 1);
                    m_encoder.encode(cb, bb, false);
                }

                // Restore the old limit so the buffer gets topped up
                // when required.
View Full Code Here

                CoderResult result     = m_encoder.encode(cb, bb, false);

                if (bbPosition == bb.position() && result.isUnderflow()) {

                    // surrogate character time
                    cb.limit(cb.limit() + 1);
                    m_encoder.encode(cb, bb, false);
                }

                // Restore the old limit so the buffer gets topped up
                // when required.
View Full Code Here

                    m_encoder.encode(cb, bb, false);
                }

                // Restore the old limit so the buffer gets topped up
                // when required.
                cb.limit(cbLimit);
                bb.flip();

                bytesRead = bb.limit();

                if (bytesRead == 0) {
View Full Code Here

                        buf.arrayOffset() + buf.position() + offset,
                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
            buf.position(offset);
            return copiedBuffer(endianness, buf, charset);
        }

        return copiedBuffer(
View Full Code Here

          if (endOfInput) {
            if (encodingBuffer.hasRemaining()) {
              result = CoderResult
                  .malformedForLength(encodingBuffer
                      .remaining());
              encodingBuffer.position(encodingBuffer.limit());
            }
          } else {
            if (encodingBuffer.hasRemaining()) {
              remains = new char[encodingBuffer.remaining()];
              encodingBuffer.get(remains);
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.