Here you can find the source of lPad(String target, String fix, int length)
public static String lPad(String target, String fix, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String lPad(String target, String fix, int length) { if ((target == null) || (fix == null) || (target.length() >= length)) return target; StringBuffer newStr = new StringBuffer(); for (int i = 0; i < length - target.length(); i++) { newStr.append(fix);//from w w w . ja v a 2s . c o m } return newStr.append(target).toString(); } public static String toString(Object obj) { if (obj == null) { return ""; } return obj.toString(); } public static String toString(Object obj, String defaultStr) { if (obj == null) { return defaultStr; } return obj.toString(); } }