I try to split some String by the byte value. Like "first\x00second" by 0x00 splitter. I found that compiler cannot combine \x token with variable.
static public ArrayList split_by_byte(String value, byte spliter) {
if (spliter < 0)
throw new IllegalArgumentException("Отрицательное значение разделителя: " + spliter);
ArrayList<String> result = new ArrayList();
String[] groups = value.split("[\\x" + spliter + "]");
for (String group : groups) {
result.add(group);
}
return result;
}
How can i use variable value in patterns like \xNN?