List of utility methods to do String Repeat
String | repeat(String s, int num) repeat StringBuilder sb = new StringBuilder(); for (int i = 0; i < num; ++i) { sb.append(s); return sb.toString(); |
String | repeat(String str, String separator, int repeat) Repeat a String repeat times to form a new String, with a String separator injected each time. if (str == null || separator == null) { return repeat(str, repeat); } else { String result = repeat(str + separator, repeat); return removeEnd(result, separator); |
String | repeat(String str, int repeat) repeat if (str == null) { return null; if (repeat < 1) { return EMPTY; int inputLen = str.length(); if (inputLen == 0 || repeat == 1) { ... |
String | repeat(String str, int repeat) Repeat a String repeat times to form a new String. StringUtils.repeat(null, 2) = null StringUtils.repeat("", 0) = "" StringUtils.repeat("", 2) = "" StringUtils.repeat("a", 3) = "aaa" StringUtils.repeat("ab", 2) = "abab" StringUtils.repeat("a", -2) = "" if (str == null) { return null; if (repeat <= 0) { return EMPTY; int inputLength = str.length(); if (repeat == 1 || inputLength == 0) { ... |