Package java.nio

Examples of java.nio.ByteBuffer.flip()


          byteBuffer.position(pos);
          byteBuffer.limit(limit);
        }
      }
     
      buffer.flip();
      return buffer;
    }
  }

 
View Full Code Here


        ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
        fc.read(buffer);
        fc.close();
        raf.close();
        buffer.flip();
       
        return new ByteBuffer[] { buffer };
    }
 
 
View Full Code Here

    ByteBuffer buffer = ByteBuffer.allocate(getContentLength());
    fc.read(buffer);
    fc.close();
    raf.close();
    buffer.flip();
   
    getNonBlockingBody().append(true, buffer);
    getNonBlockingBody().setComplete(true);
 
 
View Full Code Here

        while (in.available() != 0) {
            if (position >= limit)
                // expand buffer
                result = ByteBuffer.
                    allocate(limit <<= 1).
                    put((ByteBuffer)result.flip());
            int count = in.read(result.array(),
                position,
                limit - position);
            if (count < 0) break;
            result.position(position += count);
View Full Code Here

                position,
                limit - position);
            if (count < 0) break;
            result.position(position += count);
        }
        return (ByteBuffer)result.flip();
    }

    public void recycleByteBuffer(ByteBuffer bb) {
        byteBufferCache.put(bb);
    }
View Full Code Here

            } else if (key.isReadable()) {
                SocketChannel sc = (SocketChannel) key.channel();
                ByteBuffer buffer = ByteBuffer.allocate(10);
                buffer.clear();
                sc.read(buffer);
                buffer.flip();
                sc.write(buffer);
                sc.close();
            }
            i.remove();
        }
View Full Code Here

        bb.put((byte) ((value & 0x7F) | 0x80));
        value >>>= 7;
      }
    }

    bb.flip();
    wbc.write(bb);
    return bb.limit();
  }

  static int writeVLong(OutputStream out, long i) throws IOException {
View Full Code Here

    ByteBuffer buffer = ByteBuffer.allocate( buffersize);
    while (true) {
      int n = in.read(buffer);
      if (n == -1) break;
      totalBytesRead += n;
      buffer.flip();
    }
    return totalBytesRead;
  }

  static public long touch(FileChannel in, int buffersize) throws IOException {
View Full Code Here

      byte[] result = buffer.array();
      for (int i=0; i<buffersize; i++)
        touch += result[i];

      buffer.flip();
    }
    return touch;
  }

  /**
 
View Full Code Here

        break;
    c = s.charAt(i);
    if (c != '%')
        break;
      }
      bb.flip();
      cb.clear();
      dec.reset();
      CoderResult cr = dec.decode(bb, cb, true);
      assert cr.isUnderflow();
      cr = dec.flush(cb);
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.