Java String Pad Right rightPad(byte[] bytes, int length, byte padByte)

Here you can find the source of rightPad(byte[] bytes, int length, byte padByte)

Description

right Pad

License

Apache License

Declaration

public static byte[] rightPad(byte[] bytes, int length, byte padByte) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static byte[] rightPad(byte[] bytes, int length, byte padByte) {
        if (bytes == null) {
            return null;

        } else if (bytes.length >= length) {
            return bytes;
        }/*from   ww w  .  ja va2s. c o m*/

        byte[] newBytes = new byte[length];
        System.arraycopy(bytes, 0, newBytes, 0, bytes.length);

        for (int i = bytes.length; i < length; i++) {
            newBytes[i] = padByte;
        }

        return newBytes;
    }
}

Related

  1. rightPad(final String input, final int size)
  2. rightPad(final String str, final int size, final char padChar)
  3. rightPad(String _str, int _size, char _padChar)
  4. rightPad(String csIn, int nRequiredLength, char cFill)