Here you can find the source of fillArray(byte[] btArray, byte[] btValue, int iStartPosition, int iLength, byte btAlternateValue, int iAlign)
public static void fillArray(byte[] btArray, byte[] btValue, int iStartPosition, int iLength, byte btAlternateValue, int iAlign)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static final int ALIGN_RIGHT = 1; public static void fillArray(byte[] btArray, byte[] btValue, int iStartPosition, int iLength, byte btAlternateValue, int iAlign) { int iFillLength = btValue.length; if (iFillLength > iLength) iFillLength = iLength;//from w w w .j a v a2 s. co m int iAlternateLength = iLength - iFillLength; if (iAlign == ALIGN_RIGHT) { int iDataPosition = iStartPosition + iAlternateLength; Arrays.fill(btArray, iStartPosition, iDataPosition, btAlternateValue); System.arraycopy(btValue, 0, btArray, iDataPosition, iFillLength); } else { int iAlternatePosition = iFillLength + iStartPosition; System.arraycopy(btValue, 0, btArray, iStartPosition, iFillLength); Arrays.fill(btArray, iAlternatePosition, iAlternatePosition + iAlternateLength, btAlternateValue); } } public static void fillArray(byte[] btArray, byte btValue, int iStartPosition, int iLength) { for (int iIndex = 0; iIndex < iLength; iIndex++) btArray[iIndex + iStartPosition] = btValue; } }