if (bytes == null) { return null; } else if (bytes.length >= length) { return bytes; byte[] newBytes = new byte[length]; System.arraycopy(bytes, 0, newBytes, 0, bytes.length); for (int i = bytes.length; i < length; i++) { ...
int pads = size - input.length(); if (pads <= 0) return input; StringBuilder out = new StringBuilder(input); for (int i = pads; i > 0; i--) out.append(' '); return out.toString();
Right pad a String with a specified character.
The String is padded to the size of size .
StringUtils.rightPad(null, *, *) = null StringUtils.rightPad("", 3, 'z') = "zzz" StringUtils.rightPad("bat", 3, 'z') = "bat" StringUtils.rightPad("bat", 5, 'z') = "batzz" StringUtils.rightPad("bat", 1, 'z') = "bat" StringUtils.rightPad("bat", -1, 'z') = "bat"
if (str == null) { return null; final int pads = size - str.length(); if (pads <= 0) { return str; if (pads > PAD_LIMIT) { ...
if (_str == null) { return null; int pads = _size - _str.length(); if (pads <= 0) { return _str; return _str.concat(padding(pads, _padChar)); ...
String csOut = new String(); int nLgStringIn = csIn.length(); int nNbcharToPad = nRequiredLength - nLgStringIn; if (nNbcharToPad > 0) { csOut = csIn; for (int n = 0; n < nNbcharToPad; n++) { csOut = csOut + cFill; } else csOut = csIn.substring(0, nRequiredLength); return csOut;
String answer; if (field.length() < width) { answer = field + fill(padding, width - field.length()); } else { answer = field; return answer;
String out = ""; int toPad = length - in.length(); if (toPad < 0) { throw new IllegalArgumentException("Input string longer than requested length"); out = in + getStringRepetition(padding + "", toPad); return out;
for (int i = 0; i < len; i++) { in += pad; return in;
if (nullOrEmpty(input)) input = ""; if (input.length() >= length) return input; String padString = createPad(padding, length - input.length()); return input.concat(padString);
if (input.length() < length) { StringBuilder sb = new StringBuilder(); sb.append(input); for (int i = 0, len = length - input.length(); i < len; i++) { sb.append(pad); return sb.toString(); return input;