这就是我发现的,但在这段代码中,它读取的是你输入的内容,我不希望这样
我正在做一个名为 Knight's Tour 的程序,并在命令提示符下获得输出。我要做的就是从命令提示符中读取这些行并将其存储为一个名为 knight.txt 的输出文件。谁能帮我吗。谢谢。
try
{
//create a buffered reader that connects to the console, we use it so we can read lines
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//read a line from the console
String lineFromInput = in.readLine();
//create an print writer for writing to a file
PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
//output to the file a line
out.println(lineFromInput);
//close the file (VERY IMPORTANT!)
out.close();
}
catch(IOException e)
{
System.out.println("Error during reading/writing");
}