Android examples for java.lang:String Pad
Padding Left by filling character
import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String flushLeft(int length, String string) { return flushLeft(' ', length, string); }//from ww w .j a v a2s. c o m public static String flushLeft(char fillFlag, int length, String string) { String str = ""; StringBuilder cs = new StringBuilder(""); if (string.length() > length) { str = string; } else { for (int i = 0; i < length - string.length(); i++) { cs.append(fillFlag); } } str = string + cs.toString(); return str; } }