Java tutorial
//package com.java2s; /** * This class is part of JCodec ( www.jcodec.org ) This software is distributed * under FreeBSD License * * @author The JCodec project * */ import java.nio.ByteBuffer; public class Main { public static int readBER32(ByteBuffer input) { int size = 0; for (int i = 0; i < 4; i++) { byte b = input.get(); size = (size << 7) | (b & 0x7f); if (((b & 0xff) >> 7) == 0) break; } return size; } }