我尝试使用string.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);
Run Code Online (Sandbox Code Playgroud)