带字符串的java分割字节数组?
我想实现这样的目标:
String sentence = "Hi there over there";
String[]result = sentence.split("there");
//you get result[0] = Hi, result[1] = over
是否可以使用字节数组格式的字符串进行拆分
byte[]delimiter = "there".getBytes();
byte[]byteSentence = sentence.getBytes();
//then somehow split byteSentence using delimiter.
# 1 楼答案
当然,您可以将字节数组转换为字符串: