Package java.nio

Examples of java.nio.ByteBuffer.limit()


          last_buff.limit( orig_last_limit - (total_sofar - max_bytes) );
        }

        transport.write( raw_buffers, 0, buffer_count );

        last_buff.limit( orig_last_limit );

        int pos = 0;
        boolean stop = false;

        while( !queue.isEmpty() && !stop ) {
View Full Code Here


          DirectByteBuffer[] payloads = msg.getRawData();

          for( int x=0; x < payloads.length; x++ ) {
            ByteBuffer bb = payloads[x].getBuffer( DirectByteBuffer.SS_NET );

            int bytes_written = (bb.limit() - bb.remaining()) - orig_positions[ pos ];
            total_size -= bytes_written;

            if ( msg.getType() == Message.TYPE_DATA_PAYLOAD ){
              total_data_size -= bytes_written;
            }
View Full Code Here

              int written = 0;

              for( int i=0; i < payloads.length; i++ ) {
                ByteBuffer buff = payloads[i].getBuffer( DirectByteBuffer.SS_NET );

                message_size += buff.limit();

                if( i < x ) {  //if in front of non-empty buffer
                  written += buff.limit();
                }
                else if( i == x ) {  //is non-empty buffer
View Full Code Here

                ByteBuffer buff = payloads[i].getBuffer( DirectByteBuffer.SS_NET );

                message_size += buff.limit();

                if( i < x ) {  //if in front of non-empty buffer
                  written += buff.limit();
                }
                else if( i == x ) {  //is non-empty buffer
                  written += buff.position();
                }
              }
View Full Code Here

       
        ByteBuffer  last_bb  = null;
        for (int i=0;i<bbs.length;i++){
          ByteBuffer bb = bbs[i] = buffers[i].getBuffer(DirectByteBuffer.SS_FILE);
          int  pos = original_positions[i] = bb.position();
          if ( pos != bb.limit()){
            last_bb  = bbs[i];
          }
        }
       
        if ( last_bb != null ){
View Full Code Here

        ByteBuffer  last_bb  = null;
        for (int i=0;i<bbs.length;i++){
          ByteBuffer bb = bbs[i] = buffers[i].getBuffer(DirectByteBuffer.SS_FILE);
          int  pos = original_positions[i] = bb.position();
          if ( pos != bb.limit()){
            last_bb  = bbs[i];
          }
        }
       
        if ( last_bb != null ){
View Full Code Here

        if (channel.position() + len > length) {
            throw new EOFException();
        }
        ByteBuffer buf = ByteBuffer.wrap(b);
        buf.position(off);
        buf.limit(off + len);
        channel.read(buf);
    }

    public void seek(long pos) throws IOException {
        channel.position(pos);
View Full Code Here

    }

    public void write(byte[] b, int off, int len) throws IOException {
        ByteBuffer buf = ByteBuffer.wrap(b);
        buf.position(off);
        buf.limit(off + len);
        try {
            channel.write(buf);
        } catch (NonWritableChannelException e) {
            throw new IOException("read only");
        }
View Full Code Here

          + "/" + minLength + "]");
    }

    final ByteBuffer buffer = blockBuffer.getByteBuffer();

    buffer.limit(p + lengthGetter.getMinLength());
    buffer.position(p);

    return blockBuffer;
  }
View Full Code Here

    // existing record from buffer
    final ByteBuffer original = this.get(global, headerReader);

    // its length
    final int length = original.limit() - original.position();

    // create new buffer by copy of the original
    final PartialLoader loader = new MemoryCacheLoader(original, copy,
        headerReader);
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.