我的方法readDataFromFile()可以读取文本文件,例如:
Bird Golden Eagle Eddie
Mammal Tiger Tommy
Mammal Lion Leo
Bird Parrot Polly
Reptile Cobra Colin
第一列是动物的“类型”,第二列是“物种”,第三列是“名称”。
电流输出:
Bird Golden Eagle < (Golden and Eagle count as different substrings).
Mammal Tiger Tommy
Mammal Lion Leo
Bird Parrot Polly
Reptile Cobra Colin
我将如何使用这种useDelimiter方法将“金鹰”算作一个物种?
当前代码:
while(scanner.hasNextLine())
{
String type = scanner.next();
String species = scanner.next();
String name = scanner.next();
System.out.println(type + " " + species + " " + name);
scanner.nextLine();
addAnimal( new Animal(species, name, this) );
}
相关分类