String data = line.split(":")[1];
String location = data.split("|")[0];
String type = data.split("|")[1];
System.out.println("D: " + type);
int x = Integer.parseInt(location.split("-")[0]);
int y = Integer.parseInt(location.split("-")[1]);
int t = Integer.parseInt(type);
输入到此解析器中的原始字符串的格式类似于“DATA:3,3 | 1”。我试图将其解析为“DATA:x
,y
| t
”的格式。问题是字符串location
与字符串data
分离时为空。为什么?字符串在分割时变成空白