Here you can find the source of leftPad(String s, char paddingCharacter, int length)
public static String leftPad(String s, char paddingCharacter, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static String leftPad(String s, char paddingCharacter, int length) { if (s.length() >= length) return s; StringBuffer sb = new StringBuffer(); for (int i = s.length(); i < length; i++) { sb.append(paddingCharacter); }/*w w w . ja va 2 s . c o m*/ sb.append(s); return sb.toString(); } }