Here you can find the source of truncateBytes(byte[] inputBytes)
public static byte[] truncateBytes(byte[] inputBytes)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] truncateBytes(byte[] inputBytes) { assert inputBytes != null; assert inputBytes.length > 1; int offsetLocation = inputBytes[inputBytes.length - 1] & 0x0F; assert offsetLocation >= 0; assert offsetLocation + 3 < inputBytes.length; byte[] truncated = new byte[4]; truncated[0] = (byte) (inputBytes[offsetLocation] & 0x7F); truncated[1] = inputBytes[offsetLocation + 1]; truncated[2] = inputBytes[offsetLocation + 2]; truncated[3] = inputBytes[offsetLocation + 3]; assert (truncated[0] & 0x80) != 0x80; return truncated; }/* ww w . j a v a 2 s.c om*/ }