`
菜鸟级JAVA
  • 浏览: 93229 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

获取网站服务器的ip地址(跨过路由器ip)

    博客分类:
  • java
阅读更多
package test;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class CommandTest {

public static void main(String[] args) {
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("ipconfig");
InputStream inputStream = proc.getInputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();

byte[] data = new byte[1024];
int count = -1;
while ((count = inputStream.read(data, 0, 1024)) != -1)
outStream.write(data, 0, count);
data = null;
System.out.println(new String(outStream.toByteArray(), "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
  • 大小: 77.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics