标签:net substr ttl java readline while tostring static equal
//心跳中可以放
//自己瞎搞的,有人帮改进吗?
package netTest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class net_test_one {
public static void main(String[] args) {
try {
String[] cmd = new String[]{"cmd.exe","/c","ping www.baidu.com"}; //Window
//
Process process = Runtime.getRuntime().exec( cmd);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
ArrayList<String> list=new ArrayList<String>();
String info="";
int i=-1;
while((info=br.readLine())!=null) {
if(!"".equals(info)) {
list.add(info);
//System.out.println(info);
}
}
br.close();
if(str.indexOf("TTL")>0) {
String newStr=str.toString();
System.out.println(newStr.substring(newStr.lastIndexOf("=")+1,newStr.length()));
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
}
标签:net substr ttl java readline while tostring static equal
原文地址:http://www.cnblogs.com/jia-pf/p/7674665.html