Here you can find the source of rightPad(byte[] bytes, int length, byte padByte)
public static byte[] rightPad(byte[] bytes, int length, byte padByte)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] rightPad(byte[] bytes, int length, byte padByte) { if (bytes == null) { return null; } else if (bytes.length >= length) { return bytes; }/*from ww w . ja va2s. c o m*/ byte[] newBytes = new byte[length]; System.arraycopy(bytes, 0, newBytes, 0, bytes.length); for (int i = bytes.length; i < length; i++) { newBytes[i] = padByte; } return newBytes; } }