Package java.nio

Examples of java.nio.ByteBuffer.remaining()


            for(;;) {
                int c=in.read();
                if(c == -1 || c == 0)
                    terminate=true;

                if(buf.remaining() == 0 || terminate) {
                    if(body == null) {
                        body=new byte[buf.position()];
                        System.arraycopy(buf.array(), buf.arrayOffset(), body, 0, buf.position());
                    }
                    else {
View Full Code Here


         
          length_buffer.flip();
        }
      }else{
       
        int  rem = payload_buffer.remaining();
        int  lim  = payload_buffer.limit();
       
        if ( rem > read_lim ){
         
          payload_buffer.limit( payload_buffer.position() + read_lim );
View Full Code Here

   
      GenericMessage  gm = new GenericMessage( msg_id, msg_desc, new DirectByteBuffer( upper_initial_data ), false );
     
      DirectByteBuffer[]  payload = new GenericMessageEncoder().encodeMessage( gm )[0].getRawData();
     
      int  size = initial_data.remaining();
     
      for (int i=0;i<payload.length;i++){
       
        size += payload[i].remaining( DirectByteBuffer.SS_MSG );
      }
View Full Code Here

     
      for (int i=array_offset;i<array_offset+length;i++){
       
        ByteBuffer  buffer = buffers[i];
       
        int  space = buffer.remaining();
       
        if ( space > 0 ){
         
          if ( space < read_insert.remaining()){
           
View Full Code Here

    final ByteBuffer bb = ByteBuffer.wrap( bytes );
   
    try{
      transport.write( bb, false );
     
      if ( bb.remaining() > 0 ){
       
        transport.registerForWriteSelects(
          new TransportHelper.selectListener()
          {
              public boolean
View Full Code Here

                Object       attachment )
              {
                try{
                  int written = helper.write( bb, false );
                 
                  if ( bb.remaining() > 0 ){
                 
                    helper.registerForWriteSelects( this, null );
                   
                  }else{
                   
View Full Code Here

     
      for (int i=array_offset;i<array_offset+length;i++){
       
        ByteBuffer  buffer = buffers[i];
       
        int  max = buffer.remaining();
       
        int  read = connection.read( buffer );
       
        total += read;
       
View Full Code Here

        ByteBuffer  b = (ByteBuffer)read_buffers.get(0);
               
        int  old_limit = b.limit();
       
        if ( b.remaining() > rem ){
         
          b.limit( b.position() + rem );
        }
       
        buffer.put( b );
View Full Code Here

     
      if( shrink_remaining_buffers ) {
        bb.limit( 0 )//ensure no read into this next buffer is possible
      }
      else {
        int remaining = bb.remaining();
       
        if( remaining < 1 continue//skip full buffer

        if( !marked ) {
          pre_read_start_buffer = i;
View Full Code Here

          marked = true;
        }

        if( remaining > allowed ) {  //read only part of this buffer
          bb.limit( bb.position() + allowed )//limit current buffer
          bytes_available += bb.remaining();
          shrink_remaining_buffers = true//shrink any tail buffers
        }
        else //full buffer is allowed to be read
          bytes_available += remaining;
          allowed -= remaining;  //count this buffer toward allowed and move on to the next
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.