Here you can find the source of truncate(byte[] nextPartBytes, int partSize)
static byte[] truncate(byte[] nextPartBytes, int partSize)
//package com.java2s; //License from project: Apache License public class Main { static byte[] truncate(byte[] nextPartBytes, int partSize) { if (partSize >= nextPartBytes.length) { return nextPartBytes; }//w w w . j a v a2s .com byte[] result = new byte[partSize]; System.arraycopy(nextPartBytes, 0, result, 0, partSize); return result; } }