List of usage examples for java.nio ByteBuffer getInt
public abstract int getInt();
From source file:com.inmobi.messaging.util.AuditUtil.java
private static boolean isValidSize(ByteBuffer buffer) { int messageSize = buffer.getInt(); if (buffer.limit() != messageSize + HEADER_LENGTH) { LOG.debug("Invalid size of message in headers;found [" + (HEADER_LENGTH + messageSize) + "] expected [" + buffer.limit() + "]"); return false; }/*from w w w. j ava 2s. c om*/ return true; }
From source file:Main.java
public static int bytesToInt(byte[] bytes) { ByteBuffer buffer = ByteBuffer.allocate(4); reverseArray(bytes);//w w w . j a v a 2 s. com buffer.put(bytes, 0, bytes.length); buffer.flip();// need flip return buffer.getInt(); }
From source file:com.alibaba.otter.shared.common.utils.ByteUtils.java
public static int bytes2int(byte[] data, int offset) { ByteBuffer buffer = ByteBuffer.wrap(data, offset, 4); return buffer.getInt(); }
From source file:com.pushtechnology.diffusion.examples.runnable.RandomData.java
/** * Deserialize a {@link Binary} value as a {@link RandomData} value. * @param binary The {@link Binary} value * @return The {@link RandomData} value/* w w w. j av a2 s . c o m*/ */ static RandomData fromBinary(Binary binary) { final ByteBuffer buffer = ByteBuffer.wrap(binary.toByteArray()); final int id = buffer.getInt(); final long timestamp = buffer.getLong(); final int randomInt = buffer.getInt(); return new RandomData(id, timestamp, randomInt); }
From source file:com.aerohive.nms.engine.admin.task.licensemgr.license.processor2.PacketUtil.java
public static byte[] split(ByteBuffer buf, Header header) { header.setPacketType(buf.get());/*from w ww. j a v a 2 s . c om*/ header.setLength(buf.getInt()); header.setProtocolVersion(buf.get()); header.setSecretFlag(buf.get() == CommConst.Secret_Flag_Yes ? true : false); byte[] content = new byte[buf.remaining()]; buf.get(content); if (header.isSecretFlag()) { byte[] outb = decryptData(content); return outb; } else { return content; } }
From source file:com.alibaba.otter.shared.common.utils.ByteUtils.java
public static int bytes2int(byte[] b) { ByteBuffer buf = ByteBuffer.allocate(4); buf.put(b);// ww w . j ava 2 s . c om buf.flip(); return buf.getInt(); }
From source file:com.sm.store.Utils.java
public static void addBlockInt(Value value, Value block) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value.getData()); int k = buf.getInt() + ByteBuffer.wrap((byte[]) block.getData()).getInt(); byte[] data = putInt(k); value.setData(data);//from ww w.j a va 2 s . co m value.setVersion(value.getVersion() + 1); }
From source file:com.sm.store.Utils.java
public static void addOne(Value value) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value.getData()); int k = buf.getInt() + 1; byte[] data = putInt(k); value.setData(data);// w w w.j av a 2s . c o m value.setVersion(value.getVersion() + 1); }
From source file:org.bimserver.utils.BinUtils.java
public static int byteArrayToInt(byte[] bytes) { ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); return byteBuffer.getInt(); }
From source file:com.buaa.cfs.common.oncrpc.XDR.java
public static int fragmentSize(byte[] mark) { ByteBuffer b = ByteBuffer.wrap(mark); int n = b.getInt(); return n & 0x7fffffff; }