代码如下:
public static void main(String[] args) {
String dataString = "#01#02#03#00#05#434";
String[] infos= Arrays.stream(dataString.split("#")).filter(s -> !s.isEmpty()).toArray(String[]::new);//投向领域ID
String[] infos2 = dataString.split("#");
System.out.println("----------------------infos信息-------------------------------");
for (String info : infos) {
if (StringUtils.isEmpty(info)) {
System.out.println("空值");
}else{
System.out.println(info);
}
}
System.out.println("---------------------infos2信息--------------------------------");
for (String info : infos2) {
if (StringUtils.isEmpty(info)) {
System.out.println("空值");
}else{
System.out.println(info);
}
}
System.out.println("---------------------end--------------------------------");
}
运行结果: