如何将字符串从第一个空格中拆分出来,仅 Java 出现
我试图使用字符串拆分字符串。Index 和 string.length,但我收到一个错误,字符串超出范围。我该如何解决这个问题?
while (in.hasNextLine()) {
String temp = in.nextLine().replaceAll("[<>]", "");
temp.trim();
String nickname = temp.substring(temp.indexOf(' '));
String content = temp.substring(' ' + temp.length()-1);
System.out.println(content);