Here you can find the source of padLeft(String str, char padding, int upTo)
Parameter | Description |
---|---|
str | a parameter |
padding | a parameter |
upTo | a parameter |
public static String padLeft(String str, char padding, int upTo)
//package com.java2s; public class Main { /**/*ww w. ja v a 2 s . c o m*/ * Pad a string on the left until it reaches the designated height * @param str * @param padding * @param upTo * @return */ public static String padLeft(String str, char padding, int upTo) { StringBuilder stringBuilder = new StringBuilder(str); while (stringBuilder.length() < upTo) { stringBuilder.insert(0, padding); } return stringBuilder.toString(); } }