public ByteBuffer putInt(int value) { buf.putInt(value); return this; }
public ByteBuffer putInt(int index, int value) { buf.putInt(index, value); return this; }
/** * Puts an unsigned byte into the buffer. * * @param bb The buffer. * @param position The index in the buffer to insert the value. * @param value The value to insert. */ public static void putUnsignedInt(final ByteBuffer bb, final int position, final long value) { bb.putInt(position, (int) (value & 0xffffffffL)); }
/** * Puts an unsigned byte into the buffer. * * @param bb The buffer. * @param value The value to insert. */ public static void putUnsignedInt(final ByteBuffer bb, final long value) { bb.putInt((int) (value & 0xffffffffL)); }
public Object readObject() throws ClassNotFoundException, IOException { int objectSize = in.readInt(); if (objectSize <= 0) { throw new StreamCorruptedException("Invalid objectSize: " + objectSize); } if (objectSize > maxObjectSize) { throw new StreamCorruptedException("ObjectSize too big: " + objectSize + " (expected: <= " + maxObjectSize + ')'); } ByteBuffer buf = ByteBuffer.allocate(objectSize + 4, false); buf.putInt(objectSize); in.readFully(buf.array(), 4, objectSize); buf.position(0); buf.limit(objectSize + 4); Object answer = buf.getObject(classLoader); buf.release(); return answer; }
/** * Fills this buffer with <code>NUL (0x00)</code>. * This method moves buffer position forward. */ public ByteBuffer fill(int size) { autoExpand(size); int q = size >>> 3; int r = size & 7; for (int i = q; i > 0; i--) { putLong(0L); } q = r >>> 2; r = r & 3; if (q > 0) { putInt(0); } q = r >> 1; r = r & 1; if (q > 0) { putShort((short) 0); } if (r > 0) { put((byte) 0); } return this; }
putInt(newPos - oldPos - 4); position(newPos); return this;
putInt(intValue);