Java 経由でデフォルトのテキスト エディタでテキスト ファイルを開くの手順を使用しますか? 、このようなファイルを編集するために外部ファイルエディターを開いています。
try {
File temp = File.createTempFile("commit-", ".tmp");
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
String cmd = "rundll32 url.dll,FileProtocolHandler " + temp.getCanonicalPath();
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
System.out.println("Reached this line");
} else {
Desktop.getDesktop().edit(temp);
}
} catch (IOException|InterruptedException e) {
System.err.println(e.getMessage());
}
そのエディターが終了するまでプログラムを実行し続けたくありません。私の解決策は を使用することでしたが、外部アプリケーション (この場合は "notepad++") がまだ実行されている間waitfor()
にメッセージが表示されます。Reached this line
Windows 7、netbeans 7.3.1、および jdk 1.7 を実行しています。
また、elseブロックでそれを行う方法がわかりません。