Here you can find the source of truncateData(byte[] data, int numOfBytes)
Parameter | Description |
---|---|
data | a parameter |
read | a parameter |
private static byte[] truncateData(byte[] data, int numOfBytes)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . ja va2s .com*/ * Truncates a byte array * * @param data * @param read * @return a shorter byte array */ private static byte[] truncateData(byte[] data, int numOfBytes) { // shortcut if (data.length == numOfBytes) { return data; } else { byte[] truncated = new byte[numOfBytes]; for (int i = 0; i < truncated.length; i++) { truncated[i] = data[i]; } return truncated; } } }