public void file(){
String fileName = "hello.txt";
fileName = FileBrowser.chooseFile(true);
//Open a file and store the information into the OurList
try
{
String s = "";
File file = new File(fileName);
FileReader inputFile = new FileReader(file);
while(inputFile.read() != -1)
{
System.out.println(inputFile.read());
System.out.println();
}
}
catch(Exception exception)
{
System.out.println("Not a real file. List is already built");
}
}
所以我有这段代码的麻烦。我想从文件中逐字逐字地阅读,但现在它正在跳过其他文件。我知道它为什么会跳过,它在while循环中以及何时尝试打印,但据我所知,没有其他方法可以停止FileReader,然后将其设置为!= -1。我怎样才能让它不跳过?跳过我的文件读取器
感谢。我知道这是跳过,因为我有两个电话,但无法弄清楚如何将它存储到一个变量之前。生病的时候改变它做。再次感谢。 – user2743857
@ user2743857:请将EJP的答案标记为已接受。 –