Package java.nio

Examples of java.nio.CharBuffer.position()


                // 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


      } catch (CharacterCodingException x) {
    // Substitution is always enabled,
    // so this shouldn't happen
    throw new Error(x);
      }
      return safeTrim(ca, cb.position(), cs);
  }

    }

    static char[] decode(String charsetName, byte[] ba, int off, int len)
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

        public CharBufferWrapper next() {
            final CharBuffer message;
            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
View Full Code Here

                 */
                if (byteBuffer.hasRemaining()) {
                    // decode another batch, but remember to copy the remaining chars first
                    CharBuffer oldData = mboxCharBuffer.duplicate();
                    mboxCharBuffer.clear();
                    oldData.position(findStart);
                    while (oldData.hasRemaining()) {
                        mboxCharBuffer.put(oldData.get());
                    }
                    try {
                        decodeNextCharBuffer();
View Full Code Here

        return buf.get();
    }

    private void rewindCharacter() {
        CharBuffer buf = readerBuffer;
        assert buf.position() > 0;
        buf.position(buf.position() - 1);
    }

    private void emit(int c) throws IOException {
        assert c >= 0;
View Full Code Here

    }

    private void rewindCharacter() {
        CharBuffer buf = readerBuffer;
        assert buf.position() > 0;
        buf.position(buf.position() - 1);
    }

    private void emit(int c) throws IOException {
        assert c >= 0;
        CharBuffer buf = lineBuffer;
View Full Code Here

    }

    private void rewindCharacter() {
        CharBuffer buf = readerBuffer;
        assert buf.position() > 0;
        buf.position(buf.position() - 1);
    }

    private void emit(int c) throws IOException {
        assert c >= 0;
        CharBuffer buf = lineBuffer;
View Full Code Here

        final ByteBuffer inputBuffer = this.inputBuffer;
        inputBuffer.flip();
        try {
            while (inputBuffer.hasRemaining()) {
                final CoderResult coderResult = decoder.decode(inputBuffer, outputBuffer, false);
                if (coderResult.isUnderflow() && outputBuffer.position() == 0) {
                    return;
                }
                outputBuffer.flip();
                try {
                    boolean ok = false;
View Full Code Here

        ((StringBuilder) csq).getChars(start, end, termBuffer, termLength);
      } else if (csq instanceof CharTermAttribute) {
        System.arraycopy(((CharTermAttribute) csq).buffer(), start, termBuffer, termLength, len);
      } else if (csq instanceof CharBuffer && ((CharBuffer) csq).hasArray()) {
        final CharBuffer cb = (CharBuffer) csq;
        System.arraycopy(cb.array(), cb.arrayOffset() + cb.position() + start, termBuffer, termLength, len);
      } else if (csq instanceof StringBuffer) {
        ((StringBuffer) csq).getChars(start, end, termBuffer, termLength);
      } else {
        while (start < end)
          termBuffer[termLength++] = csq.charAt(start++);
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.