あなたはfileout
に何かを書き込むことはありません:
Scanner in = new Scanner(System.in);
System.out.print("Enter the input file: ");
String inputFileName = in.next();
System.out.print("Enter the output file: ");
String outputFileName = in.next();
String poemFilename = "poem.txt";
String poemoutFilenamo = "newpoem";
int lineNum = 1;
File poemFile = new File(poemFilename);
Scanner fileIn = new Scanner(poemFile);
PrintWriter fileout = new PrintWriter(poemoutFilenamo);
System.out.printf("Read in %s.\nWrote out %s.\n",inputFileName, outputFileName);
ProcessBuilder Poemin = new ProcessBuilder("Notepad.exe", poemFilename);
Poemin.start();
if (fileIn.hasNextLine()) {
do {
String line = fileIn.nextLine();
System.out.printf("/*" + lineNum + "*/ %s\n", line);
lineNum++;
} while (fileIn.hasNextLine());;
ProcessBuilder Poemout = new ProcessBuilder("Notepad.exe", poemoutFilenamo);
Poemout.start();
}
in.close();
fileIn.close();
fileout.close();
は、メモ帳のウィンドウでこれを印刷する必要があります。ファイルを作成しましたが、ファイルは空です。
は、私はあなたが
fileout.printf("/*" + lineNum + "*/ %s\n", line);
をしたいと考えているし、また、あなたは第二のプロセスを起動する前fileout
を閉じる必要があります。
2番目のプロセスビルダーのプロセスを開始する場所の前に 'fileout.close()'を***に移動します。ファイルを使用する前にファイルにフラッシュする必要があります。また、編集可能(未使用)である必要があります。 –
@HovercraftFullOfEelsあなたの提案をありがとう。私はちょうどそれを試み、それはまだ空のウィンドウをもたらします:( – Rish