Package java.nio

Examples of java.nio.ByteBuffer.order()


    }

    public static ExFatSuperBlock read(ExFatFileSystem fs) throws IOException {

        final ByteBuffer b = ByteBuffer.allocate(SIZE);
        b.order(ByteOrder.LITTLE_ENDIAN);
        fs.getApi().read(0, b);
       
        /* check OEM name */

        final byte[] oemBytes = new byte[OEM_NAME.length()];
View Full Code Here


    private void ensureSize(int i) {
        check();
        if (buffer.remaining() < i) {
            int newCap = Math.max(buffer.limit() << 1, buffer.limit() + i);
            ByteBuffer newBuffer = buffer.isDirect() ? ByteBuffer.allocateDirect(newCap) : ByteBuffer.allocate(newCap);
            newBuffer.order(buffer.order());
            buffer.flip();
            newBuffer.put(buffer);
            buffer = newBuffer;
        }
    }
View Full Code Here

        return header == LOCSIG || header == EXTSIG || header == CENSIG;
    }

    private static ByteBuffer getByteBuffer(int capacity) {
        ByteBuffer b = ByteBuffer.allocate(capacity);
        b.order(ByteOrder.LITTLE_ENDIAN);
        return b;
    }

    private static void read(ByteBuffer bb, FileChannel ch) throws IOException {
        bb.clear();
View Full Code Here

        return ch;
    }

    public static ByteBuffer getByteBuffer(int capacity) {
        ByteBuffer b = ByteBuffer.allocate(capacity);
        b.order(ByteOrder.LITTLE_ENDIAN);
        return b;
    }

    public static void putUnsignedShort(ByteBuffer bb, int value, int pos) {
        bb.putShort(pos, (short) (value & 0xffff));
View Full Code Here

        }
    }

    public ByteBuffer toByteBuffer(int index, int length) {
        ByteBuffer buf = buffer.toByteBuffer(index, length);
        if (buf.order() == ByteOrder.BIG_ENDIAN) {
            return buf.order(ByteOrder.LITTLE_ENDIAN);
        } else {
            return buf.order(ByteOrder.BIG_ENDIAN);
        }
    }
View Full Code Here

    }

    public ByteBuffer toByteBuffer(int index, int length) {
        ByteBuffer buf = buffer.toByteBuffer(index, length);
        if (buf.order() == ByteOrder.BIG_ENDIAN) {
            return buf.order(ByteOrder.LITTLE_ENDIAN);
        } else {
            return buf.order(ByteOrder.BIG_ENDIAN);
        }
    }
View Full Code Here

    public ByteBuffer toByteBuffer(int index, int length) {
        ByteBuffer buf = buffer.toByteBuffer(index, length);
        if (buf.order() == ByteOrder.BIG_ENDIAN) {
            return buf.order(ByteOrder.LITTLE_ENDIAN);
        } else {
            return buf.order(ByteOrder.BIG_ENDIAN);
        }
    }


    private static short swapShort(short value) {
View Full Code Here

  public static void decrypt(byte[] data, int key) {
    build_crypt_table();

    ByteBuffer buf = ByteBuffer.wrap(data, 0, data.length);
    buf.order(ByteOrder.LITTLE_ENDIAN);

    int seed = 0xeeeeeeee;
    for(int i = 0; i < data.length>>>2; i++) {
      seed += crypt_table[0x400 + (key & 0xFF)];
      int ch = buf.getInt(i<<2);
View Full Code Here

    short make_sum = 0;
    int data_len = data.length;
    full_len = 1 + 4 + 4 + 2 + 1 + 2 + 4 + data_len;
   
    ByteBuffer buff = ByteBuffer.allocate(100);
    buff.order(ByteOrder.LITTLE_ENDIAN);
    buff.put(byte_order);
    buff.putInt(full_len);
    buff.putInt(serial);
    buff.putShort(package_type);
    buff.put(version);
View Full Code Here

  /** Creates a new Input for reading from a byte array.
   * @param buffer An exception is thrown if more bytes than this are read. */
  public ByteBufferInput (ByteBuffer buffer, int offset, int count) {
    ByteBuffer newBuffer = buffer.duplicate();
    newBuffer.order(byteOrder);
    newBuffer.limit(count);
    newBuffer.rewind();
    setBuffer(newBuffer, offset, count);
  }

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.