Package java.nio

Examples of java.nio.CharBuffer.remaining()


        CharBuffer cb = CharBuffer.wrap(name);
        ByteBuffer out = ByteBuffer.allocate(name.length()
                                             + (name.length() + 1) / 2);

        while (cb.remaining() > 0) {
            CoderResult res = enc.encode(cb, out,true);

            if (res.isUnmappable() || res.isMalformed()) {

                // write the unmappable characters in utf-16
View Full Code Here


        LOG.warn(status.toString());
    }

    private int getNextCharacter() throws IOException {
        CharBuffer buf = readerBuffer;
        if (buf.remaining() == 0) {
            buf.clear();
            int read = reader.read(buf);
            buf.flip();
            assert read != 0;
            if (read < 0) {
View Full Code Here

    }

    private void emit(int c) throws IOException {
        assert c >= 0;
        CharBuffer buf = lineBuffer;
        if (buf.remaining() == 0) {
            if (buf.capacity() == BUFFER_LIMIT) {
                throw new IOException(MessageFormat.format(
                        "Line is too large (near {0}:{1}, size={2}, record-number={3})",
                        path,
                        currentPhysicalHeadLine,
View Full Code Here

    InputStreamReader stdOut = new InputStreamReader(p.getInputStream());
    LinkedList<CharBuffer> l = new LinkedList<CharBuffer>();
    int r = -1;
    CharBuffer b = null;
    do {
      if (b == null || b.remaining() < b.capacity() / 3) {
        b = CharBuffer.allocate(512);
        l.add(b);
      }
      r = stdOut.read(b);
    } while (r != -1);
View Full Code Here

          if (charsRead == -1) {
            // if we received EOF before last event processing attempt, then we
            // have done everything we can
            break;
          } else if (charsRead == 0 && eventsProcessed == 0) {
            if (buffer.remaining() == buffer.capacity()) {
              // If we get here it means:
              // 1. Last time we called fill(), no new chars were buffered
              // 2. After that, we failed to process any events => no newlines
              // 3. The unread data in the buffer == the size of the buffer
              // Therefore, we are stuck because the client sent a line longer
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()
View Full Code Here

                        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 "
View Full Code Here

                                * 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()
View Full Code Here

                        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 "
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.