List of utility methods to do String Pad Left
String | leftPad(String str, int len, char c) left Pad if (str.length() >= len) return str; StringBuilder ret = new StringBuilder(); while (ret.length() < len - str.length()) ret.append(c); return ret.append(str).toString(); |
String | leftPad(String str, int length) Pads a string left with spaces return (leftPad(str, length, ' ')); |
String | leftPad(String str, int length, char c) left Pad if (str.length() >= length) { return str; StringBuffer buf = new StringBuffer(); for (int i = 0; i < length - str.length(); i++) { buf.append(c); buf.append(str); ... |
String | leftPad(String str, int length, char padding) left Pad final int paddingLength = length - str.length(); if (paddingLength < 0) return str; final StringBuilder builder = new StringBuilder(length); while (builder.length() < paddingLength) builder.append(padding); builder.append(str); return builder.toString(); ... |
String | leftPad(String str, int maxLength, char placeholder) left Pad if (str == null) { throw new NullPointerException("str should not be null"); if (maxLength < str.length()) { throw new IllegalArgumentException("str length should not be greater than: " + maxLength); String temp = str; while (temp.length() < maxLength) { ... |
String | leftPad(String str, int num, String padStr) left Pad if (num <= 0) { return str; StringBuilder sb = new StringBuilder(str.length() + num); while (num-- > 0) { sb.append(padStr); sb.append(str); ... |
String | leftPad(String str, int pad) left Pad if (str == null) return null; if (str.length() >= pad) return str; int len = pad - str.length(); for (int i = 0; i < len; i++) str = " " + str; return str; ... |
String | leftPad(String str, int size) left Pad return leftPad(str, size, ' '); |
String | leftPad(String str, int size) Left pad a String with spaces (' '). return leftPad(str, size, ' '); |
String | leftPad(String str, int size) left Pad return leftPad(str, size, ' '); |