byte
The default byte order of byte buffer is always BIG_ENDIAN.
18551856185718581859186018611862186318641865
} final int RESULT_SIZE = (1 + (17 * 4)); ByteBuffer res = ByteBuffer.allocate(RESULT_SIZE); res.order(ByteOrder.BIG_ENDIAN); res.put(FILE_RESP_INFO); res.putLong(file_size); res.putInt(file_type);
30143015301630173018301930203021302230233024
if (port == 0) { port = fd.getLocalPort(); } ByteBuffer reply = ByteBuffer.allocate(3); reply.order(ByteOrder.nativeOrder()); reply.put(INET_REP_OK); reply.putShort((short) (port & 0xFFFF)); return reply; }
147148149150151152153154155156157
protected ByteBuffer control(EPID caller, int command, ByteBuffer out) throws Pausable { if (command == CTRL_OP_GET_WINSIZE) { // TODO: hmm, how do we do that? // for now, we always respond 80x25. ByteBuffer bb = ByteBuffer.allocate(8); bb.order(ByteOrder.nativeOrder()); bb.putInt(80); bb.putInt(25); return bb; } else { throw ERT.badarg();
166167168169170171172173174175176
: EFile.FT_REGULAR; final int RESULT_SIZE = (1 + (29 * 4)); ByteBuffer res = ByteBuffer.allocate(RESULT_SIZE); res.order(ByteOrder.BIG_ENDIAN); res.put(EFile.FILE_RESP_INFO); res.putLong(file_size); res.putInt(file_type);
192193194195196197198199200201202
// Prepares newData to be endian compliant with original buffer // data. if(audioFormat.getEndian() == AudioFormat.BIG_ENDIAN) { newData.order(ByteOrder.BIG_ENDIAN); } else { newData.order(ByteOrder.LITTLE_ENDIAN); }
196197198199200201202203204205206
{ newData.order(ByteOrder.BIG_ENDIAN); } else { newData.order(ByteOrder.LITTLE_ENDIAN); } // Keeps data unchanged if storeed before the original buffer offset // index. // Takes care of original data array type (byte, short or int).
254255256257258259260261262263264
iis.close(); } //create a ByteBuffer from the deflated data ByteBuffer out = ByteBuffer.wrap( baos.toByteArray() ); //with proper byte ordering out.order( byteOrder ); return out; } /** * Reads data form byte buffer. Searches for either * <code>miCOMPRESSED</code> data or <code>miMATRIX</code> data.
1819202122232425262728
public class MarshallersTest extends TestCase { private <T> void checkByteOrder(Marshaller<T> m, T value) { { ByteBuffer buf = m.toBytes(value); buf.order(ByteOrder.BIG_ENDIAN); assertEquals(value, m.fromBytes(buf)); } { ByteBuffer buf2 = m.toBytes(value); buf2.order(ByteOrder.LITTLE_ENDIAN);
2324252627282930313233
buf.order(ByteOrder.BIG_ENDIAN); assertEquals(value, m.fromBytes(buf)); } { ByteBuffer buf2 = m.toBytes(value); buf2.order(ByteOrder.LITTLE_ENDIAN); assertEquals(value, m.fromBytes(buf2)); } } private <T> void checkMoreCapacity(Marshaller<T> m, T value) {
6465666768697071727374
int i = 0; while (audioInputStream.read(samplesIn, 0, frameSize) != -1) { if (frameSize != 1) { ByteBuffer bb = ByteBuffer.wrap(samplesIn); bb.order(ByteOrder.LITTLE_ENDIAN); short shortVal = bb.getShort(); sampleData[i] = shortVal; } else { sampleData[i] = samplesIn[0]; }