Java tutorial
//package com.java2s; public class Main { public static String lpad(String str, int length, String ch) { str = (str == null) ? "" : str; StringBuffer buf = new StringBuffer(); int idx = str.length(); while (idx < length) { buf.append(ch); idx++; } buf.append(str); return buf.toString(); } }