用java編程語言,如何實現在命令窗口輸入nbtstat -a ip 得到的效果
可以使用Runtime命令去執行
public static void main(String[] args) {
String path = "D:\public.bat";
Runtime run = Runtime.getRuntime();
try {
Process process = run.exec("nbtstat -a ip“);
//將調用結果打印到控制台上
InputStream in = process.getInputStream();
while (in.read() != -1) {
System.out.println(in.read());
}
in.close();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}