展开全部
import java.io.*;
import java.util.*;
public class GetRoutInfo {
public static void main(String[] args) throws Exception {
StringBuffer buffer = new StringBuffer();
Process process = Runtime.getRuntime().exec("cmd /c route print");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()) );
String line = "";
while ( (line = bufferedReader.readLine()) != null) {
System.out.println(line);
}
}
}
结果:
===========================================================================
接口列表e68a8462616964757a686964616f31333335313137
12...b8 88 e3 38 0b c8 ......Realtek PCIe GBE Family Controller
1...........................Software Loopback Interface 1
30...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
34...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
33...00 00 00 00 00 00 00 e0 Microsoft 6to4 Adapter #2
===========================================================================
IPv4 路由表
===========================================================================
活动路由:
网络目标 网络掩码 网关 接口 跃点数
.....
===========================================================================
永久路由:
网络地址 网络掩码 网关地址 跃点数
....
===========================================================================
IPv6 路由表
===========================================================================
活动路由:
如果跃点数网络目标 网关
...
===========================================================================
永久路由:
无