Here you can find the source of unPad(byte[] bytes)
private static byte[] unPad(byte[] bytes)
//package com.java2s; /*//from ww w. j a v a 2 s .c o m * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ public class Main { private static byte[] unPad(byte[] bytes) { int padded = (int) bytes[bytes.length - 1]; int targetLength = bytes.length - padded; byte[] out = new byte[targetLength]; System.arraycopy(bytes, 0, out, 0, targetLength); return out; } }