Package java.nio

Examples of java.nio.ByteBuffer.order()


    if (element instanceof PcapPacketImpl) {
      final PcapPacketImpl p = (PcapPacketImpl) element;

      final ByteBuffer old = p.getRecordByteBuffer();
      if (old.order() == this.editor.order()) {
        buffer = old.slice();
      } else {
        buffer =
            PcapRecordIterator.convertByteOrder(BufferUtils.copy(old),
                this.editor.order());
View Full Code Here


      throw new IllegalArgumentException("Editor is no empty."
          + " Can only add new block record to completely empty file.");
    }

    final ByteBuffer b = ByteBuffer.allocate(PcapBlockRecord.HEADER_LENGTH);
    b.order(editor.order());

    PcapBlockRecordImpl.initBuffer(b);

    /*
     * Add our new block record at byte offset 0 to the editor.
View Full Code Here

      return b;
    }

    final int length = b.limit() - b.position();
    final ByteBuffer r = ByteBuffer.allocate(length);
    r.order(order);

    r.putInt(b.getInt());
    r.putInt(b.getInt());
    r.putInt(b.getInt());
    r.putInt(b.getInt());
View Full Code Here

    final int fraction = (int) (millis % 1000);
    final int micros = fraction * 1000;

    final ByteBuffer b = ByteBuffer.allocate(PcapPacketRecord.HEADER_LENGTH
        + included);
    b.order(editor.order());

    PcapPacketRecordImpl.initBuffer(b, included, original, seconds, micros);

    b.position(PcapPacketRecord.HEADER_LENGTH);
    b.put(data);
View Full Code Here

   */
  public static ByteBuffer createBuffer(final int length, final ByteOrder order) {

    final ByteBuffer data = ByteBuffer.allocate(PcapPacketRecord.HEADER_LENGTH
        + length);
    data.order(order);
    final int included = length;
    final int original = included;
    final long millis = System.currentTimeMillis();
    final long seconds = millis / 1000;
    final int fraction = (int) (millis % 1000);
View Full Code Here

    /*
     * Change the byte order in any buffers in the cache as well
     */
    for (int i = 0; i < cache.size(); i++) {
      final ByteBuffer b = cache.get(i).getByteBuffer();
      b.order(order);

    }
  }

  /*
 
View Full Code Here

  public static long gzipUncompressedSize(File src) throws IOException {
    FileChannel in = new RandomAccessFile(src, "r").getChannel();

    ByteBuffer b = ByteBuffer.allocate(128);
    b.order(ByteOrder.LITTLE_ENDIAN);

    in.read(b, in.size() - b.remaining());

    final long size = b.getInt(b.limit() - 4);
View Full Code Here

  public static long gzipUncompressedCRC32(File src) throws IOException {
    FileChannel in = new RandomAccessFile(src, "r").getChannel();

    ByteBuffer b = ByteBuffer.allocate(128);
    b.order(ByteOrder.LITTLE_ENDIAN);

    in.read(b, in.size() - b.remaining());

    final long size = b.getInt(b.limit() - 8);
View Full Code Here

   */
  public static ByteBuffer slice(ByteBuffer buffer) {

    final ByteOrder o = buffer.order();
    final ByteBuffer r = buffer.slice();
    r.order(o);

    return r;
  }

  /**
 
View Full Code Here

   */
  public static ByteBuffer asReadonly(ByteBuffer buffer) {

    final ByteOrder o = buffer.order();
    final ByteBuffer r = buffer.asReadOnlyBuffer();
    r.order(o);

    return r;
  }

  public static ByteBuffer copy(ByteBuffer buffer) {
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.