org.aion.avm.utilities.analyze.ByteReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaee-rt Show documentation
Show all versions of javaee-rt Show documentation
An Execution Environment for Java SCOREs
package org.aion.avm.utilities.analyze;
import java.nio.ByteBuffer;
public class ByteReader {
private ByteBuffer buffer;
public ByteReader(byte[] bytes) {
buffer = ByteBuffer.wrap(bytes);
}
// The types u1, u2, and u4 represent an unsigned one-, two-, or four-byte quantity, respectively
// ByteBuffer is read in a big-endian byte order
public byte readU1() {
return buffer.get();
}
public short readU2() {
return buffer.getShort();
}
public int readU4() {
return buffer.getInt();
}
public byte[] readNBytes(int n) {
byte[] utf8 = new byte[n];
buffer.get(utf8);
return utf8;
}
public int position() {
return buffer.position();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy