-1
私は次のコードを試しましたが、文字列に固執します。lineFromInput = in.readLine();この行がなければ、txtファイルは空です。1000 +ラインのコンソールデータをtxtファイルに入れたいのですが?
iが使用されるコードは次のとおり
try
{
File file = new File("out.txt"); //Your file
FileOutputStream fos = new FileOutputStream(file);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String lineFromInput = in.readLine();
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
ps.println(lineFromInput);
// System.out.println("This goes to out.txt");
}
catch(IOException e)
{
System.out.println("Error during reading/writing");
}
「*つぶれていますか?」とはどういう意味ですか?テキスト行を入力するのを待っていて、Enterキーを押すと(System.inから読み込んでいるため)*続けるでしょう。 – Andreas
コンソール内で1000行以上のデータを生成しているプロセスを実行するために使用しているコードは何ですか(これが実際に実行している場合)。あなたが本当に探しているものは、おそらく 'BufferedReader in =新しいBufferedReader(新しいInputStreamReader(myProcess.getInputStream()));の代わりに:' System.in'です。もちろん、これに関連するコードが少しだけありますが、これがあなたがやろうとしているものであれば、その情報を提供することができます。 – DevilsHnd