Random: Add join for an array.

This commit is contained in:
asofold 2015-11-15 05:27:46 +01:00
parent 3ebde69877
commit 5fe02d75d2
1 changed files with 31 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package fr.neatmonster.nocheatplus.utilities;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@ -34,6 +35,28 @@ public class StringUtil {
fdec1.setMinimumIntegerDigits(1);
}
/**
* Join parts with link, starting from startIndex.
* @param input
* @param startIndex
* @param link
* @return
*/
public static <O extends Object> String join(O[] input, int startIndex, String link) {
return join(Arrays.copyOfRange(input, startIndex, input.length), link);
}
/**
* Join parts with link.
*
* @param input
* @param link
* @return
*/
public static <O extends Object> String join(O[] input, String link) {
return join(Arrays.asList(input), link);
}
/**
* Join parts with link.
*
@ -66,14 +89,14 @@ public class StringUtil {
for (final char c : chars){
String hex = Integer.toHexString((int) c);
switch (hex.length()){
case 1:
hex = "000" + hex;
break;
case 2:
hex = "00" + hex;
break;
case 3:
hex = "0" + hex;
case 1:
hex = "000" + hex;
break;
case 2:
hex = "00" + hex;
break;
case 3:
hex = "0" + hex;
}
for (final String s : out){
final String[] split = s.split("\\u" + hex);