Here you can find the source of leftPad(String base, int length, char pad)
public static String leftPad(String base, int length, char pad)
//package com.java2s; //License from project: Apache License public class Main { public static String leftPad(String base, int length, char pad) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length - base.length(); i++) { sb.append(pad);/*from ww w . j a v a 2 s.c o m*/ } sb.append(base); return sb.toString(); } }