Package java.nio

Examples of java.nio.ByteBuffer.mark()


    final ByteBuffer view = BufferUtils.duplicate(buffer);
    final int capacity = view.capacity();
    boolean status = true;

    for (int i = 0; i < count && view.position() + MAX_HEADER_LENGTH < capacity; i++) {
      view.mark();
      long length = headerReader.readLength(view);
      int p = view.position() + (int) length;

      if (pattern.match(view) == false) {
        status = false;
View Full Code Here


    private void realloc(int size) {
        ByteBuffer buffer = ByteBuffer.allocate(size);
        this.buffer.flip();
        buffer.put(this.buffer);
        buffer.mark();
        this.buffer = buffer;
    }
}
View Full Code Here

                            byte c = safeGet(encode);
                            if (c != '=') {
                                lElem[index++] = c;
                            } else {
                                if (!encode.hasRemaining()) break;
                                encode.mark();
                                byte c1 = safeGet(encode);
                                if (c1 == '\n') continue;
                                int d1 = Character.digit((char)(c1 & 0xFF), 16);
                                if (d1 == -1) {
                                    encode.reset();
View Full Code Here

                                int d1 = Character.digit((char)(c1 & 0xFF), 16);
                                if (d1 == -1) {
                                    encode.reset();
                                    break;
                                }
                                encode.mark();
                                if (!encode.hasRemaining()) break;
                                byte c2 = safeGet(encode);
                                int d2 = Character.digit((char)(c2 & 0xFF), 16);
                                if (d2 == -1) {
                                    encode.reset();
View Full Code Here

            }
            receiver=new Receiver(sock, channel, matrix, jg);
            receiver.start();

            ByteBuffer bb=ByteBuffer.allocate(16);
            bb.mark();

            start=System.currentTimeMillis();
            for(int i=0; i < num_msgs; i++) {
                bb.reset();
                bb.putInt(i);
View Full Code Here

            Message msg;
            byte[] msg_data=null;
            long total_time;
            double msgs_per_sec=0;
            ByteBuffer rb=ByteBuffer.allocate(16);
            rb.mark();

            packet=new DatagramPacket(buf, buf.length);
            while(num_received <= num_msgs) {
                try {
                    if(jg) {
View Full Code Here

    @Override
    protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {

  ByteBuffer buffer = in.buf();
  buffer.mark();
  boolean success = parse(buffer, out);
  if (!success) {
      buffer.reset();
      return false;
  }
View Full Code Here

                return;
            }
            gotLen = buffer.limit() - buffer.position();
            bytes = new byte[gotLen];

            buffer.mark();
            while (buffer.hasRemaining()) {
                buffer.get(bytes);
                out.write(bytes, 0, gotLen);
            }
            buffer.reset();
View Full Code Here

            // And now, write the bytes until we have none
            while ( nbStored > 0 )
            {
                if ( remaining > nbStored )
                {
                    pageData.mark();
                    pageData.position( pagePos );
                    pageData.put( bytes, bytes.length - nbStored, nbStored );
                    pageData.reset();
                    nbStored = 0;
                }
View Full Code Here

                    pageData.reset();
                    nbStored = 0;
                }
                else
                {
                    pageData.mark();
                    pageData.position( pagePos );
                    pageData.put( bytes, bytes.length - nbStored, remaining );
                    pageData.reset();
                    pageNb++;
                    pageData = pageIos[pageNb].getData();
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.