gpt4 book ai didi

JAVA 修剪()不工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:00:23 30 4
gpt4 key购买 nike

<分区>

这是我所拥有的:

public void readFile(String fileToOpen) {
File myFile = new File(fileToOpen);
try {
Scanner inFile = new Scanner(myFile);
while (inFile.hasNext()) {
String input = inFile.nextLine();
String [] readString = input.split(",");
for (int i = 0; i < readString.length; i++) {
readString[i].trim();
}
System.out.println(readString[0] + readString[1] + readString[2] + readString[3] + readString[4] + readString[5]);
Point myPoint = new Point(Integer.parseInt(readString[1]), Integer.parseInt(readString[2]));
if (readString[0].toLowerCase().equals("man")) {
Man myMan = new Man(myPoint, Integer.parseInt(readString[3]), Integer.parseInt(readString[4]), readString[5]);
this.myList.add(myMan);
} else if (readString[0].toLowerCase().equals("woman")) {
Woman myWoman = new Woman(myPoint, Integer.parseInt(readString[3]), Integer.parseInt(readString[4]), readString[5]);
this.myList.add(myWoman);
} else {
inFile.close();
throw new IllegalArgumentException();
}
}
inFile.close();
}

我知道它并不完美,我只是在学习。然而,trim() 应该在这里工作......

我的输入文件是:

man, 300, 200, 3, 2, Bill

如果我要将修剪后的字符串加在一起,我应该得到:

man30020032Bill

但我得到:

man 300 200 3 2 Bill

我不知道为什么。有人可以帮忙吗?

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com