关于Runtime.getRuntime().exec的问题,不知java中是否能解决我的问题 把执行dos命令的代码放到一个class里去,jsp去调用,得到ping的结果 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我使用的是javabean,我在bean的类中建立了一个循环检测的函数,然后通过网页调用该函数,实现检测网络的目地。目前的问题是在执行时有dos窗口闪出,我想知道如何不让dos窗口出现 我直接把它加到jsp页面中,没有dos窗口跳出。 我在JDK上运行 却有DOS窗口出现 速度较快 下面是我写的函数public boolean setcheck(String address,int num){ try { InputStream ou = Runtime.getRuntime().exec("ping "+address+" -n "+num+" ").getInputStream(); InputStreamReader ir= new InputStreamReader(ou); BufferedReader in = new BufferedReader(ir); while((name=in.readLine())!=null) { if(name.startsWith("Request timed out.")) { state=false; } if(name.startsWith("Reply from")) { state=true; } } }catch(Exception e) { } return state;}调用页面<% boolean state=ConBean.setcheck(address,1); if(state) { %> <td width="3%" align="center"> </td><td width="13%" align="center"><img src=".//WIN98.ICO" width="32" height="32"><br> <font color="green"> <% out.println( ""+address+""); %> </fond> </td> <% } if(!state) { %> <td width="3%" align="center"> </td><td width="13%" align="center"><img src=".//WIN98.ICO" width="32" height="32"><br> <font color="red"> <% out.println(""+address+""); } %> </fond> </td> <% if(i%5==0) { %> <td width="3%" align="center"> </td></tr> <tr><td width="3%" ></td><td width="10%" align="center"></td></tr><tr> <% i=0; } } %> .net ? .net? 求解! 数据库 Oracle 创建过程带编译错误……?求解! hibernate删除问题 寻求高手HTTPCLIENT。。。。。。 struts,高手帮帮我撒,谢谢了~! java调用存储过程取返回值问题 struts标签库的问题? 求有关JSTL的电子书,最好是英文原版的,见书结贴。 这是用小程序编写的一个数字时钟~可是日期和现在差一月!请高手帮忙改改~谢谢谢谢谢! 谁有JDOM解析 XML的例子? Jabber开源项目启动,欢迎志同道合者加盟!
然后通过网页调用该函数,实现检测网络的目地。目前的问题是在执行时
有dos窗口闪出,我想知道如何不让dos窗口出现
{
try
{
InputStream ou = Runtime.getRuntime().exec("ping "+address+" -n "+num+" ").getInputStream();
InputStreamReader ir= new InputStreamReader(ou);
BufferedReader in = new BufferedReader(ir);
while((name=in.readLine())!=null)
{
if(name.startsWith("Request timed out."))
{
state=false;
}
if(name.startsWith("Reply from"))
{
state=true;
}
}
}
catch(Exception e)
{
}
return state;
}
调用页面
<%
boolean state=ConBean.setcheck(address,1);
if(state)
{ %>
<td width="3%" align="center"> </td><td width="13%" align="center"><img src=".//WIN98.ICO" width="32" height="32"><br>
<font color="green"> <%
out.println( ""+address+"");
%> </fond> </td>
<%
}
if(!state)
{
%>
<td width="3%" align="center"> </td><td width="13%" align="center"><img src=".//WIN98.ICO" width="32" height="32"><br>
<font color="red"> <% out.println(""+address+"");
}
%>
</fond>
</td>
<%
if(i%5==0)
{ %>
<td width="3%" align="center"> </td></tr>
<tr><td width="3%" ></td><td width="10%" align="center"></td></tr><tr>
<%
i=0;
}
}
%>