@Test public void testRepeat() { assertEquals("", StringUtils.repeat(0, null)); assertEquals(" ", StringUtils.repeat(1, null)); assertEquals(" ", StringUtils.repeat(1, " ")); assertEquals(",", StringUtils.repeat(1, ",1a")); assertEquals(" ", StringUtils.repeat(2, null)); assertEquals(" ", StringUtils.repeat(2, " ")); assertEquals(",1", StringUtils.repeat(2, ",1a")); assertEquals(" ", StringUtils.repeat(3, null)); assertEquals(" ", StringUtils.repeat(3, " ")); assertEquals(",1a", StringUtils.repeat(3, ",1a")); assertEquals(" ", StringUtils.repeat(7, null)); assertEquals(" ", StringUtils.repeat(7, " ")); assertEquals(",1a,1a,", StringUtils.repeat(7, ",1a")); }
public static String repeat(int length, String str) { if (length <= 0) { return ""; } if (isBlank(str)) { str = " "; } StringBuffer sb = new StringBuffer(length + str.length()); for (int index = 0; index < length / str.length() + 1; index ++) { sb.append(str); } return sb.substring(0, length); }
StringUtils { public static String repeat(int length, String str) { if (length <= 0) { return ""; } if (isBlank(str)) { str = " "; } StringBuffer sb = new StringBuffer(length + str.length()); for (int index = 0; index < length / str.length() + 1; index ++) { sb.append(str); } return sb.substring(0, length); } }
StringUtils { public static String repeat(int length, String str) { if (length <= 0) { return ""; } if (isBlank(str)) { str = " "; } StringBuffer sb = new StringBuffer(length + str.length()); for (int index = 0; index < length / str.length() + 1; index ++) { sb.append(str); } return sb.substring(0, length); } private  StringUtils(); }
StringUtils { public static String repeat(int length, String str) { if (length <= 0) { return ""; } if (isBlank(str)) { str = " "; } StringBuffer sb = new StringBuffer(length + str.length()); for (int index = 0; index < length / str.length() + 1; index ++) { sb.append(str); } return sb.substring(0, length); } private  StringUtils(); static String byte2Base64String(byte[] value); static byte[] Base64String2Byte(String base64Str); static String byte2HexString(byte b); static byte[] hexString2Byte(String input); static String byte2HexString(byte[] bs); static boolean isBlank(String str); static boolean isChinese(String str); static boolean isChinese(char c); static String merge(Collection<?> coll); static String merge(Collection<?> coll, char separate); static String merge(Collection<?> coll, String separate); static String merge(String[] str); static String merge(String[] str, char separate); static String merge(String[] str, String separate); static String merge(String str, int length); static String merge(String str, int length, String separate); static String merge(String str, int length, char separate); static String repeat(int length, String str); static String[] split(String s); static String[] split(String s, boolean trimTokens, boolean ignoreEmptyTokens); static String[] split(String s, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens); static boolean string2Boolean(String str, boolean defaultValue); static int string2Int(String str, TypeUtils.Radix radix, int defaultValue); static long string2Long(String str, TypeUtils.Radix radix, long defaultValue); static float string2Float(String str, float defaultValue); static double string2Double(String str, double defaultValue); static long string2Size(String size, long defaultValue); static long stirng2TimePeriod(String timePeriod, long defaultValue); static String truncate(String src, int length); static String xmlEscape(String str); static String xmlUnescape(String str); }
StringUtils { public static String repeat(int length, String str) { if (length <= 0) { return ""; } if (isBlank(str)) { str = " "; } StringBuffer sb = new StringBuffer(length + str.length()); for (int index = 0; index < length / str.length() + 1; index ++) { sb.append(str); } return sb.substring(0, length); } private  StringUtils(); static String byte2Base64String(byte[] value); static byte[] Base64String2Byte(String base64Str); static String byte2HexString(byte b); static byte[] hexString2Byte(String input); static String byte2HexString(byte[] bs); static boolean isBlank(String str); static boolean isChinese(String str); static boolean isChinese(char c); static String merge(Collection<?> coll); static String merge(Collection<?> coll, char separate); static String merge(Collection<?> coll, String separate); static String merge(String[] str); static String merge(String[] str, char separate); static String merge(String[] str, String separate); static String merge(String str, int length); static String merge(String str, int length, String separate); static String merge(String str, int length, char separate); static String repeat(int length, String str); static String[] split(String s); static String[] split(String s, boolean trimTokens, boolean ignoreEmptyTokens); static String[] split(String s, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens); static boolean string2Boolean(String str, boolean defaultValue); static int string2Int(String str, TypeUtils.Radix radix, int defaultValue); static long string2Long(String str, TypeUtils.Radix radix, long defaultValue); static float string2Float(String str, float defaultValue); static double string2Double(String str, double defaultValue); static long string2Size(String size, long defaultValue); static long stirng2TimePeriod(String timePeriod, long defaultValue); static String truncate(String src, int length); static String xmlEscape(String str); static String xmlUnescape(String str); static final char DEFAULT_SEPARATOR; static final String DELIMITERS; }