我目前正在尝试从数据文件中扫描文本而它不识别空间,因此在打印时将其计为2个字符串。
while (scanner.hasNextLine())
{
String id = scanner.next();
String species = scanner.next();
String name = scanner.next();
System.out.println(id + "\t" + species + "\t" + name);
lineOfText = scanner.nextLine();
}
这是我所拥有的代码,并且在物种之间的空间线上,它打印出物种的后半部分,因此不会在最后添加名称。