try{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd /c netstat -ano | findstr 9090");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
String s = null;
if ((s = stdInput.readLine()) != null) {
int index=s.lastIndexOf(" ");
String sc=s.substring(index, s.length());
rt.exec("cmd /c Taskkill /PID" +sc+" /T /F");
}
JOptionPane.showMessageDialog(null, "Server Stopped");
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Something Went wrong with server");
}
————————————————
版权声明:本文为CSDN博主「洱海之月」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Elegant_Kevin/article/details/130069957