以整数形式返回8个无符号位。
/* from n o w j a v a . c o m*/ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Iterator; import org.apache.log4j.Logger; public class Main{ /** * Returns 8 unsigned bits as an integer. * * @param buf * @return */ final public static int getUnsignedByte(ByteBuffer buf) { return ((int) buf.get()) & 0xff; } }