Here you can find the source of leftPad(String str, int maxLength, char placeholder)
public static String leftPad(String str, int maxLength, char placeholder)
//package com.java2s; //License from project: Open Source License public class Main { public static String leftPad(String str, int maxLength, char placeholder) { if (str == null) { throw new NullPointerException("str should not be null"); }// w w w.j a v a 2 s.c o m if (maxLength < str.length()) { throw new IllegalArgumentException("str length should not be greater than: " + maxLength); } String temp = str; while (temp.length() < maxLength) { temp = placeholder + temp; } return temp; } }