Package java.nio

Examples of java.nio.CharBuffer.limit()


            CoderResult result = decoder.decode(inbuf, dest, true);
            dest.flip();

            if (result.isUnderflow()) { // done reading
                // make sure there is at least one extra character
                if (dest.limit() == dest.capacity()) {
                    dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
                    dest.flip();
                }
                return dest;
            } else if (result.isOverflow()) { // buffer too small; expand
View Full Code Here


            } else if (result.isMalformed() || result.isUnmappable()) {
                // bad character in input

                // report coding error (warn only pre 1.5)
                if (!getSource().allowEncodingErrors()) {
                    log.error(new SimpleDiagnosticPosition(dest.limit()),
                              "illegal.char.for.encoding",
                              charset == null ? encodingName : charset.name());
                } else {
                    log.warning(new SimpleDiagnosticPosition(dest.limit()),
                                "illegal.char.for.encoding",
View Full Code Here

                if (!getSource().allowEncodingErrors()) {
                    log.error(new SimpleDiagnosticPosition(dest.limit()),
                              "illegal.char.for.encoding",
                              charset == null ? encodingName : charset.name());
                } else {
                    log.warning(new SimpleDiagnosticPosition(dest.limit()),
                                "illegal.char.for.encoding",
                                charset == null ? encodingName : charset.name());
                }

                // skip past the coding error
View Full Code Here

                // skip past the coding error
                inbuf.position(inbuf.position() + result.length());

                // undo the flip() to prepare the output buffer
                // for more translation
                dest.position(dest.limit());
                dest.limit(dest.capacity());
                dest.put((char)0xfffd); // backward compatible
            } else {
                throw new AssertionError(result);
            }
View Full Code Here

                inbuf.position(inbuf.position() + result.length());

                // undo the flip() to prepare the output buffer
                // for more translation
                dest.position(dest.limit());
                dest.limit(dest.capacity());
                dest.put((char)0xfffd); // backward compatible
            } else {
                throw new AssertionError(result);
            }
        }
View Full Code Here

 
  public ByteArrayCodepointIterator(byte[] bytes, Charset charset) {
    CharBuffer cb = charset.decode(ByteBuffer.wrap(bytes));
    buffer = cb.array();
    position = cb.position();
    limit = cb.limit();
  }

}
View Full Code Here

            fromLineFound = fromLineMathcer.find();
            if (fromLineFound) {
                message = mboxCharBuffer.slice();
                message.position(findEnd + 1);
                saveFindPositions(fromLineMathcer);
                message.limit(fromLineMathcer.start());
            } else {
                /* We didn't find other From_ lines this means either:
                 *  - we reached end of mbox and no more messages
                 *  - we reached end of CharBuffer and need to decode another batch.
                 */
 
View Full Code Here

          buffer.flip();

          logger.debug("read {} characters", buffer.remaining());

          counterGroup.addAndGet("characters.received",
              Long.valueOf(buffer.limit()));

          builder.append(buffer.array(), buffer.position(), buffer.length());
        }

        if (builder.charAt(builder.length() - 1) == '\n') {
View Full Code Here

    h.check(cb.hasArray(), false);
    h.check(cb.hasRemaining(), true);
    h.check(cb.isDirect(), false);
    h.check(cb.isReadOnly(), true);
    h.check(cb.length(), 3);
    h.check(cb.limit(), 7);
    h.check(cb.position(), 4);
    h.check(cb.remaining(), 3);
    try
      {
        cb.compact();
View Full Code Here

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

    h.check(slice.capacity(), 3);
    try
      {
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.