Java examples for java.lang:byte Array
pad byte array from Right
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { byte[] array = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int length = 2; System.out.println(java.util.Arrays .toString(padRight(array, length))); }/*from w w w . ja v a2s. com*/ public static byte[] padRight(byte[] array, int length) { if (array.length >= length) { return array; } byte[] buffer = new byte[length]; System.arraycopy(array, 0, buffer, 0, array.length); return buffer; } }