이것은 내가 찾은 것입니다. 그러나이 코드에서 여러분이 넣은 것에 대한 행을 읽었습니다. 나는 그것을 원하지 않습니다.명령 프롬프트에서 출력을 가져 와서 언어를 사용하여 텍스트 파일을 만드는 방법 Java
저는 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");
}
당신이 원하는 것을하지 않는 코드를 게시하는 데 별 도움이되지 않습니까? – EJP