易截截图软件、单文件、免安装、纯绿色、仅160KB

如何用Java实现Ping(思路)

RT.
Java code:

public class CmdTest {

private static final long serialVersionUID = -2650474785662737262L;

public static void main(String[] args) throws Exception {
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("cmd /c ping 127.0.0.1");
DealStream errStream = new DealStream(p.getErrorStream(),"Err");
DealStream outStream = new DealStream(p.getInputStream(),"Out");
new Thread(errStream).start();
new Thread(outStream).start();
int exitValue = p.waitFor();
System.out.println("exitValue -- > " + exitValue);
}

}
class DealStream implements Runnable{
private InputStream is;
private String type;

public DealStream(InputStream is,String type){
this.is = is;
this.type = type;
}

public void run(){
try{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String temp = null;
while((temp = br.readLine()) != null){
System.out.println(type + "-->" + temp + "\n");
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
is.close();
}catch(Ex


相关问答:

怎么用Java实现定时执行某程序 - Java / Java SE

我想用Java写一个程序,就是我想在运行代码后,在指定的时间打开某程序,例如我运行代码后,讲在12:00打开"D:\Program Files\Tencent\QQ2009\Bin\QQ.exe"这个程序,求高人指点。还有可能的话在指定的时间 ......

asp 调用java写的webservice - Web 开发 / ASP

在asp里怎么调用java写的webservice方法,有很多方法
- <message name="RtPnrIn">
  <part name="bstrPnrNO" type="s:string" /> 
  <part name ......

关于AJAX和JSP的一些小问题~ - Java / Web 开发

我JSP的页面是:
<%@ page language="java" contentType="text/html; charset=gb2312"
  %>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......

java使用代理访问网址 - Java / Java SE

代码如下 ,我想通过代理访问一些网址,但是不知道如何测试代理成功,我想通过访问“http://www.blogger.com/”来看看是否代理成功,但是也不能访问,出现异常“Unexpected end of file from server”,但是如果不这 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号