Here you can find the source of leftPad(String targetStr, char appendChar, int length)
public static String leftPad(String targetStr, char appendChar, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String leftPad(String targetStr, char appendChar, int length) { if (targetStr == null) { return null; }/*from w ww . j a v a2 s . c om*/ int len = targetStr.length(); while (len++ < length) { targetStr = appendChar + targetStr; } return targetStr; } }