我正在尝试将用户输入写入文本文件。以下是我的尝试。我无法弄清楚这有什么问题。
public class Source {
public static void main(String[] args) throws IOException {
Scanner Scanner = new Scanner(System.in);
String fileName = "write.txt";
FileWriter FileWriter = new FileWriter(fileName);
BufferedWriter bufferedWriter = new BufferedWriter(FileWriter);
System.out.println("Give an input to write to txt file");
String input = Scanner.next();
while(input != null){
input = Scanner.next();
System.out.println(input);
//bufferedWriter.write(input);
//bufferedWriter.close();
}
}
}