Package java.nio

Examples of java.nio.CharBuffer.remaining()


            default:
                throw new IllegalArgumentException( "padding: " + padding );
        }

        CharBuffer in = CharBuffer.wrap( val );
        int expectedLength = (int)( in.remaining() * encoder.averageBytesPerChar() ) + 1;

        skip( prefixLength ); // make a room for the length field
        int oldPos = position();
        encoder.reset();

View Full Code Here


      return null;
    ByteBuffer bb = ByteBuffer.allocate(content.length());
    CharBuffer cb = CharBuffer.wrap(content);
    while (cb.hasRemaining()) {
      char c = cb.get();
      if (c == '%' && cb.remaining() >= 2) {
        char uc = cb.get();
        char lc = cb.get();
        int u = Character.digit(uc, 16);
        int l = Character.digit(lc, 16);
        if (u != -1 && l != -1)
View Full Code Here

        StringBuilder builder = new StringBuilder();

        while (reader.read(buffer) != -1) {
          buffer.flip();

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

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

          builder.append(buffer.array(), buffer.position(), buffer.length());
View Full Code Here

    CharBuffer buf = CharBuffer.allocate(BUF_SIZE);
    long total = 0;
    while (from.read(buf) != -1) {
      buf.flip();
      to.append(buf);
      total += buf.remaining();
      buf.clear();
    }
    return total;
  }
View Full Code Here

    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();
        h.fail("testBasic");
      }
View Full Code Here

                final CoderResult coderResult = decoder.decode(inputBuffer, outputBuffer, false);
                if (coderResult.isOverflow()) {
                    outputBuffer.flip();
                    boolean ok = false;
                    try {
                        writer.write(outputBuffer.array(), outputBuffer.arrayOffset(), outputBuffer.remaining());
                        ok = true;
                    } finally {
                        if (! ok) {
                            inputBuffer.clear();
                        }
View Full Code Here

            }
            if (cr.isOverflow()) {
                if (isAutoExpand()) {
                    switch (expandedState) {
                    case 0:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.averageBytesPerChar()));
                        expandedState++;
                        break;
                    case 1:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.maxBytesPerChar()));
                        expandedState++;
View Full Code Here

                    case 0:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.averageBytesPerChar()));
                        expandedState++;
                        break;
                    case 1:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.maxBytesPerChar()));
                        expandedState++;
                        break;
                    default:
                        throw new RuntimeException("Expanded by "
                                + (int) Math.ceil(in.remaining() * encoder.maxBytesPerChar())
 
View Full Code Here

                        autoExpand((int) Math.ceil(in.remaining() * encoder.maxBytesPerChar()));
                        expandedState++;
                        break;
                    default:
                        throw new RuntimeException("Expanded by "
                                + (int) Math.ceil(in.remaining() * encoder.maxBytesPerChar())
                                + " but that wasn't enough for '" + val + "'");
                    }
                    continue;
                }
            }
View Full Code Here

            }
            if (cr.isOverflow()) {
                if (isAutoExpand()) {
                    switch (expandedState) {
                    case 0:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.averageBytesPerChar()));
                        expandedState++;
                        break;
                    case 1:
                        autoExpand((int) Math.ceil(in.remaining() * encoder.maxBytesPerChar()));
                        expandedState++;
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.