MCPcopy Create free account
hub / github.com/antlr/codebuff / padEnd

Method padEnd

corpus/java/training/guava/base/Strings.java:120–131  ·  view source on GitHub ↗

Returns a string, of length at least minLength, consisting of string appended with as many copies of padChar as are necessary to reach that length. For example, padEnd("4.", 5, '0') returns "4.000" padEnd("2010", 3, '!') returns {@code "2

(String string, int minLength, char padChar)

Source from the content-addressed store, hash-verified

118 * @return the padded string
119 */
120 public static String padEnd(String string, int minLength, char padChar) {
121 checkNotNull(string); // eager for GWT.
122 if (string.length() >= minLength) {
123 return string;
124 }
125 StringBuilder sb = new StringBuilder(minLength);
126 sb.append(string);
127 for (int i = string.length(); i < minLength; i++) {
128 sb.append(padChar);
129 }
130 return sb.toString();
131 }
132
133 /**
134 * Returns a string consisting of a specific number of concatenated copies of an input string. For

Callers

nothing calls this directly

Calls 4

toStringMethod · 0.65
checkNotNullMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected