byte
The default byte order of byte buffer is always BIG_ENDIAN.
6162636465666768697071
} 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()];
231232233234235236237238239240241
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; } }
375376377378379380381382383384385
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();
127128129130131132133134135136137
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));
159160161162163164165166167168169
} } 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); } }
160161162163164165166167168169170
} 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); } }
162163164165166167168169170171172
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) {
6869707172737475767778
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);
7980818283848586878889
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);
5354555657585960616263
/** 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); }