Java Utililty Methods String Left Justify

List of utility methods to do String Left Justify

Description

The list of methods to do String Left Justify are organized into topic(s).

Method

StringLeftAdjust(String s, int len, char pad)
Pad the string s on the right side with pad until len characters.
char[] ca = new char[len];
int k;
if (s == null) {
    k = 0;
} else {
    k = s.length();
for (int i = 0; i < len && i < k; i++) {
...
StringleftJustify(long v, int width)
The leftJustify() method pads a string to a specified length by adding spaces on the right, thus justifying the string to the left margin.
return leftJustify(Long.toString(v), width);
StringleftJustify(String s, int maxLength)
Left justify a string, and fill to a given length with the blanks.
return leftJustify(s, maxLength, ' ');
StringleftJustify(String sourceString, int targetLen, char pad)
left Justify
int sourceLen = sourceString.length();
char[] buffer = new char[targetLen];
if (targetLen < sourceLen) {
    sourceString.getChars(0, targetLen, buffer, 0);
} else {
    int i = 0;
    while (i < sourceLen) {
        buffer[i] = sourceString.charAt(i++);
...
StringleftJustify(String str, int width)
left Justify
return suffix(str, width, " ");
StringleftJustify(String string, int width)
left Justify
StringBuilder buffer = new StringBuilder();
buffer.append(string);
int deficit = width - string.length();
for (int i = 0; i < deficit; i++) {
    buffer.append(' ');
return buffer.toString();
StringleftJustify(String value, int width)
leftJustify left-justifies a String value, space padding to width characters if the string is less than width.
StringBuffer sb = new StringBuffer(width);
sb.append(value);
for (int i = sb.length(); i < width; i++)
    sb.append(' ');
if (sb.length() > width)
    sb.setLength(width);
return sb.toString();
StringleftJustifyString(String s, int width)
Left justify a string in a fixed-width field, using blanks for padding.
return leftJustifyString(s, width, ' ');
StringleftJustifyText(String originalValue, int length, char padCharacter)
left Justify Text
String encodedValue = originalValue;
if (originalValue == null) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < length; i++) {
        sb.append(padCharacter);
    encodedValue = sb.toString();
} else {
...