Package java.nio

Examples of java.nio.ByteBuffer.position()



        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];
          }
        }
       
View Full Code Here


                    PooledByteBuffer p_buffer = event.getBuffer();
                   
                    try{
                      ByteBuffer  bb = p_buffer.toByteBuffer();
                                         
                      bb.position( 0 );
                     
                      int  read = bb.remaining();

                      bb.get( buffer, write_pos, read );
                     
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 {
View Full Code Here

        channel.force(true);
    }

    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

        (int) nanos / 1000);

    /*
     * Now copy the data into our new record buffer
     */
    buffer.position(PcapPacketRecord.HEADER_LENGTH);
    buffer.put(data);
    buffer.clear();

    this.raw.add(buffer);
  }
 
View Full Code Here

    if (hasNext() == false) {
      throw new IllegalStateException(
          "Exhausted all records while searching for timestamp");
    } else {
      buffer = next();
      s = (Long) SECONDS.read(buffer, buffer.position());
      m = (Long) MICROS.read(buffer, buffer.position());

    }

    // Check if we are not already passed it
View Full Code Here

      throw new IllegalStateException(
          "Exhausted all records while searching for timestamp");
    } else {
      buffer = next();
      s = (Long) SECONDS.read(buffer, buffer.position());
      m = (Long) MICROS.read(buffer, buffer.position());

    }

    // Check if we are not already passed it
    if (seconds < s || (seconds == s && micros < m)) {
View Full Code Here

    if (hasNext() == false) {
      throw new IllegalStateException(
          "Exhausted all records while searching for timestamp");
    } else {
      buffer = next();
      s = (Long) SECONDS.read(buffer, buffer.position());
      m = (Long) MICROS.read(buffer, buffer.position());
    }

    // Check if we are not already passed it
    if (seconds < s || (seconds == s && micros < m)) {
View Full Code Here

      throw new IllegalStateException(
          "Exhausted all records while searching for timestamp");
    } else {
      buffer = next();
      s = (Long) SECONDS.read(buffer, buffer.position());
      m = (Long) MICROS.read(buffer, buffer.position());
    }

    // Check if we are not already passed it
    if (seconds < s || (seconds == s && micros < m)) {
      return seek(seconds, micros, start, length / 2.);
View Full Code Here

    while (hasNext()) {
      p = getPosition();
      ByteBuffer buffer = next();

      s = (Long) SECONDS.read(buffer, buffer.position());
      m = (Long) MICROS.read(buffer, buffer.position());

      if (s > seconds || (s == seconds && m >= micros)) {
        setPosition(p);
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.