Create a padding byte array buffer. - Java java.nio

Java examples for java.nio:ByteBuffer Array

Description

Create a padding byte array buffer.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte paddingByte = 2;
        int paddingLength = 2;
        System.out.println(java.util.Arrays.toString(CreatePaddingBuffer(
                paddingByte, paddingLength)));
    }/*from  w w  w . ja  v  a2  s  .co m*/

    /**
     * Create a padding buffer.
     * @param paddingByte
     * @param paddingLength
     * @return
     */
    public static byte[] CreatePaddingBuffer(byte paddingByte,
            int paddingLength) {
        byte[] pading = new byte[paddingLength];
        for (int i = 0; i < pading.length; i++) {
            pading[i] = paddingByte;
        }

        return pading;
    }
}

Related Tutorials