我可能已找到解决方案:InputStream will not reset to beginning 如何将此代码实现到我的代码中? 我需要阅读的文本文件不止一次使用:如何多次读取文本文件
while (true){
final String checkUsername = brUsername.readLine();
if (checkUsername == null) {
break;
}
if (checkUsername.equals(usernameInput)) {
correctUsername = true;
}
}
的读者和作家:
FileWriter fwUsername = new FileWriter("Username.txt", true);
FileReader frUsername = new FileReader("Username.txt");// reads the created file Username.txt
PrintWriter pwUsername = new PrintWriter(fwUsername, true);
BufferedReader brUsername = new BufferedReader(frUsername);
我不能做到这一点,而循环多次。没有错误,但while循环跳过。 1.我该如何重复这个循环? 2.如果我不能重复这个循环,我如何存储所有的值,以便我可以检查它? 3.此链接可能有解决方案,但我不知道如何做答案:How to reopen a file from a input stream。 我是初学者,所以我没有太多知识。我正在使用的代码:dropbox.com/s/du1u01f27t0ok2o/codehelp.txt?dl=0
这将是很好,添加什么语言,你想这样做。 – Bas 2014-10-04 10:07:58
读取文件后,您可以尝试'frUsername.reset()'将读取位置重置为文件的开头(或者最后一个设置为“mark”,但我猜这里没有)。 – Tom 2014-10-04 10:36:27