外部アプリ起動 SWT
Program program = Program.findProgram(".html");
if (program != null) {
program.launch(strUrl);
}
外部アプリ起動 Java1.6
if (!Desktop.isDesktopSupported()) {
return;
}
Desktop desktop = Desktop.getDesktop();
//
if (desktop.isSupported(Desktop.Action.OPEN)) {
File file = new File("C:\\test.txt");
desktop.open(file);
}
外部アプリ起動 Java1.5
String[] command = { "notepad.exe"};
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new File("C:\\temp"));//作業フォルダの設定
Map<String, String> env = builder.environment();//環境変数を取得
Process process = builder.start();
InputStream stream = process.getErrorStream();
while (true) {
int c = stream.read();
if (c == -1) {
stream.close();
break;
}
System.out.print((char) c);
}
最終更新:2009年05月14日 14:05