Skip to content

StringUtils.rightPad

Signature: StringUtils.rightPad(inputString, size, padString*)

Returns: String result - the right-padded String or original String if no padding is necessary, or null if inputString is null

Right pad the inputString with a space (default) or the optional padString.

Parameters

Type Name Description Default
String inputString the String to pad out, may be null
Integer size the size to pad to
String padString* (optional) the String to pad with ' '

Example

// Example: right pad a string to a fixed width.

StringUtils.rightPad(
    '1', // inputString
    10,  // size
    '0'  // padString (optional)
);       // 1000000000

StringUtils.rightPad(
    '1',     // inputString
    10       // size
    // padString omitted (defaults to space)
) + "- curtains";  // 1          - curtains