Here you can find the source of lpad(final String input, final String padCode, final int toLength)
public static final String lpad(final String input, final String padCode, final int toLength)
//package com.java2s; //License from project: Apache License public class Main { public static final String lpad(final String input, final String padCode, final int toLength) { if (input != null && input.length() < toLength) { final StringBuffer sb = new StringBuffer(input); while (sb.length() < toLength) { sb.insert(0, padCode);/*from ww w .j a v a 2 s .c o m*/ } return sb.toString(); } else { return input; } } }