我目前正在为我和我的朋友编写一个Java应用程序,并且包含一个大问题... 当我尝试读取txt文件时,它会打印出具有奇怪字符的行并且每个caracter都由一个空格分隔。 我tryed在不同的文件夹中的多个TXT文件和打印我同样的事情,每次...(我tryed做一个扫描仪和一个BufferedReader的代码,它仍然是同样的问题文件读取中每个caracter之间的Java空格
这里是我的代码:
BufferedReader br = new BufferedReader(new FileReader(_file));
String website = "";
String username = "";
String password = "";
int usedTimes = 0;
String currentLine;
while ((currentLine = br.readLine()) != null) {
if(currentLine.startsWith("Web Site")) website = currentLine.split(":")[1];
else if(currentLine.startsWith("User Name")) username = currentLine.split(":")[1];
else if(currentLine.startsWith("Password")) password = currentLine.split(":")[1];
else if(currentLine.startsWith("Password Use Count"))
{
usedTimes = Integer.parseInt(currentLine.split(":")[1]);
passwords.add(new Password(website, username, password, usedTimes));
website = "";
username = "";
password = "";
usedTimes = 0;
}
}
br.close();
所以,如果你们谁知道答案,请告诉我,这将是巨大
!非常感谢您阅读本文,直到这里! Julien。
你没有显示任何输出内容的代码。请告诉我们输出完成的地方。 – Marvin
哦,是的,我只是添加了一个system.out.println(currentLine);在线 – Julien