List of utility methods to do String Repeat
String | createRepeatedString(char c, int length) Create a string of the same char char[] vals = new char[length]; Arrays.fill(vals, c); return String.valueOf(vals); |
String | deleteRepeatStr(String repeatStr, String separator) delete this repeat character if (repeatStr == null) { return null; StringBuffer noRepeatStr = new StringBuffer(); String[] strElement = repeatStr.split(separator); List strlist = new ArrayList(); for (int i = 0; i < strElement.length; i++) { if (!strlist.contains(strElement[i])) { ... |
String | repeat(String in, int count) repeat if ((in == null) || (count < 1)) return ""; StringBuffer out = new StringBuffer(); for (int i = 0; i < count; i++) { out.append(in); return out.toString(); |
String | repeat(String item, int count) Creates string where given item string is repeated count times.
StringBuilder result = new StringBuilder(); if (!isEmpty(item)) for (int i = 0; i < count; i++) result.append(item); return result.toString(); |
String | repeat(String pattern, int count) repeat final StringBuilder builder = new StringBuilder(); for (int i = 0; i < count; i++) { builder.append(pattern); return builder.toString(); |
String | repeat(String s, int cnt) Concatentate the given string cnt times StringBuffer sb = new StringBuffer(); for (int i = 0; i < cnt; i++) { sb.append(s); return sb.toString(); |
String | repeat(String s, int times) repeat StringBuffer sb = new StringBuffer(); for (int i = 0; i < times; i++) { sb.append(s); return sb.toString(); |
String | repeat(String s, int times) Create a string by repeating a substring by specified times. return repeat(s, times, null);
|
String | repeat(String s, int times) Generate a string that repeats/replicates a string a specified number of times. StringBuilder sb = new StringBuilder(); for (int i = 0; i < times; ++i) { sb.append(s); return sb.toString(); |
String | repeat(String str, int count) repeat if (count < 0) throw new IllegalArgumentException("count must be positive"); char[] chars = str.toCharArray(); char[] result = new char[chars.length * count]; int resultIdx = 0; for (int i = 0; i < count; i++, resultIdx += chars.length) System.arraycopy(chars, 0, result, resultIdx, chars.length); return new String(result); ... |