我在寫代碼刪除一個字的文本文件,當用戶輸入,但我不能似乎得到掃描器部工作文本文件錯誤掃描
public static void Option2Method() throws IOException
{
File inputFile = new File("wordlist.txt");
File tempFile = new File("TempWordlist.txt");
String lineToRemove = JOptionPane.showInputDialog(null, "Enter a word to remove");
Scanner reader = new Scanner(inputFile);
Scanner writer =new Scanner(tempFile);
String currentLine;
while((currentLine = reader.nextLine()) != null)
{
String trimmedLine = currentLine.trim();
if(trimmedLine.equals(lineToRemove)) continue;
writer.print(currentLine + "\n");
}
reader.close();
writer.close();
inputFile.delete();
tempFile.renameTo(inputFile);
}
當你有問題嗎? – 2013-04-07 10:49:04
給writer.print一個錯誤(currentLine +「\ n」);它說它找不到符號 – user2205055 2013-04-07 10:51:23