62,616
社区成员
发帖
与我相关
我的任务
分享
//这里可以写打开eclipse,通过进程调用start()应该就可以了
private void runOnce() {
String s = "eclipse.exe ";
try {
java.io.BufferedReader id = new java.io.BufferedReader(new java.io.
FileReader(ID_FILENAME));
String ss = id.readLine();
if (ss != null)
s = ss;
id.close();
}
catch (Exception e) {
//System.out.println(e);
}
try {
int i = 0;
java.lang.Process p = java.lang.Runtime.getRuntime().exec( "Tlist -s ");
InputStream[] inStreams =
new InputStream[] {
h.getInputStream(), h.getErrorStream()};
ConsoleTextArea cta = new
ConsoleTextArea(inStreams);
System.out.println(cta.toString());
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.
InputStreamReader(p.getInputStream()));
String ss = " ";
while ( (ss = in.readLine()) != null) {
if (ss.indexOf(s) != -1) {
i++;
}
}
in.close();
if (i > 1) {
javax.swing.JOptionPane.showMessageDialog(this, "程序已经运行! ");
//这里可以写打开eclipse,通过进程调用start()应该就可以了
}
}
catch (Exception e) {
javax.swing.JOptionPane.showMessageDialog(this, "未找到Tlist程序或I/O错误! ");
}
}