如何得到本地计算机的网络状态,比如网络是否通,数据上传和下发速率...

yipinrfr 2003-11-25 02:56:39
如上:
...全文
98 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
handsomeghost 2003-11-25
  • 打赏
  • 举报
回复
根据返回的字符传来判断网络是否连通
handsomeghost 2003-11-25
  • 打赏
  • 举报
回复
<%@ page import="java.io.*" %>

<%
Runtime runtime = Runtime.getRuntime();
Process process =null;
String line=null;
InputStream is =null;
InputStreamReader isr=null;
BufferedReader br =null;
String ip="你要ping的ip";
//自行修改上面的ip位址
try
{
process =runtime.exec("ping "+ip);
is = process.getInputStream();
isr=new InputStreamReader(is);
br =new BufferedReader(isr);
out.println("<pre>");
while( (line = br.readLine()) != null )
{
out.println(line);
out.flush();
}
out.println("</pre>");
is.close();
isr.close();
br.close();
}
catch(IOException e )
{
out.println(e);
runtime.exit(1);
}
%>
yipinrfr 2003-11-25
  • 打赏
  • 举报
回复
to handsomeghost(方鸿渐) 那样程序的移植性不就受到影响了?
handsomeghost 2003-11-25
  • 打赏
  • 举报
回复
可以试一试调用Windows API

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧