public static String leftPad(final String str, final int size, final char padChar) {
        if (str == null) {
            return null;
        }
        final int pads = size - str.length();
        if (pads <= 0) {
            return str; // returns original String when possible
        }
        if (pads > PAD_LIMIT) {
            return leftPad(str, size, String.valueOf(padChar));
        }
        return repeat(padChar, pads).concat(str);
    }
<p>Left pad a String with a specified String.</p>

<p>Pad to a size of {@code size}.</p>

<pre>
StringUtils.leftPad(null, *, *)      = null
StringUtils.leftPad("", 3, "z")      = "zzz"
StringUtils.leftPad("bat", 3, "yz")  = "bat"
StringUtils.leftPad("bat", 5, "yz")  = "yzbat"
StringUtils.leftPad("bat", 8, "yz")  = "yzyzybat"
StringUtils.leftPad("bat", 1, "yz")  = "bat"
StringUtils.leftPad("bat", -1, "yz") = "bat"
StringUtils.leftPad("bat", 5, null)  = "  bat"
StringUtils.leftPad("bat", 5, "")    = "  bat"
</pre>

@param str    the String to pad out, may be null
@param size   the size to pad to
@param padStr the String to pad with, null or empty treated as single space
@return left padded String or original String if no padding is necessary,
{@code null} if null String input
tika-core/src/main/java/org/apache/tika/utils/StringUtils.java