这是我的代码:
import java.io.*;
public class PingTest
{
public static void main (String [] args) throws IOException, InterruptedException
{
Runtime.getRuntime().exec(new String[]
{"cmd","/k","start","cmd","/c","ping localhost"});
}
}
它像我想要的那样 ping 本地主机,但它不会保持打开状态。完成后立即关闭。我该怎么做才能解决这个问题?