java 测试IP
public static long calSpeed(String ip) {
Runtime runtime = Runtime.getRuntime(); // 获取当前程序的运行进对象
Process process = null; // 声明处理类对象
String line = null; // 返回行信息
InputStream is = null; // 输入流
InputStreamReader isr = null; // 字节流
BufferedReader br = null;
try {
process = runtime.exec("ping " + ip +" -w 1000"); // PING
is = process.getInputStream(); // 实例化输入流
isr = new InputStreamReader(is);// 把输入流转换成字节流
br = new BufferedReader(isr);// 从字节中读取文本
while ((line = br.readLine()) != null) {
if (line.contains("TTL")) {
int begin = line.indexOf("TTL=");
String value = line.substring(begin+4,line.length());
return Integer.valueOf(value);
}
}
} catch (IOException e) {
System.out.println(e);
runtime.exit(1);
}finally{
if(is!=null){
try {
is.close();
} catch (IOException e) {
}
}
if(isr!=null){
try {
isr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(br!=null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return 10000;
}
java 测试IP的更多相关文章
- 如何使用 Java 测试 IBM Systems Director 的 REST API
转自: http://www.ibm.com/developerworks/cn/aix/library/au-aix-systemsdirector/section2.html 如何使用 Java ...
- Java 根据IP获取地址
用淘宝接口:(源码:java 根据IP地址获取地理位置) pom.xml: <!-- https://mvnrepository.com/artifact/net.sourceforge.jre ...
- Java测试工具
1. 开源测试工具: http://www.open-open.com/43.htm 2. 10款常用的JAVA测试工具 :http://developer.51cto.com/art/200 ...
- 在Jmeter中使用自定义编写的Java测试代码
我们在做性能测试时,有时需要自己编写测试脚本,很多测试工具都支持自定义编写测试脚本,比如LoadRunner就有很多自定义脚本的协议,比如"C Vuser","Java ...
- Java根据ip地址获取Mac地址,Java获取Mac地址
Java根据ip地址获取Mac地址,Java获取Mac地址 >>>>>>>>>>>>>>>>>&g ...
- Java获取ip地址的几种方法
以下内容介绍下java获取ip地址的几种思路. 1.直接利用java.net.InetAddress类获取,不过这种方法只在windows环境下有效,在linux环境下只能获取localhost地址( ...
- 用fiddler测试ip轮询
测试业务: 服务端根据域名配置了三台服务器ip,测试ip轮询的逻辑 测试方法: 使用fiddler配置hosts即可 1.1.1.1 第一台ip 1.1.1.1 第二台ip 1.1.1.1 第三台ip ...
- Vultr VPS测试IP $5/月KVM-512MB/15G SSD/1T
vultr主要卖点是:SSD硬盘.超低价格.全球13个机房.10Gb服务器带宽.3GHz CPU.性能优异.vultr vps详细评测可参考这篇文章. 以下是vutlr vps官方提供的测试IP地址: ...
- Java将ip字符串转换成整数的代码
下面代码是关于Java将ip字符串转换成整数的代码,希望对各位有较大用途. public class IpUtil { public static int Ip2Int(String strIp){ ...
随机推荐
- startActivityForResult与onActivityResult
androidActivity之间的跳转不只是有startActivity(Intent i)的,startActivityForResult(Intent intent, int requestCo ...
- unity LineRenderer
using UnityEngine; using System.Collections; public class Spider:MonoBehaviour { private LineRendere ...
- Oracle Sql优化之Rownum的使用
1.rownum:rownum是一个伪列,需要在数据取出来后,rownum才会有值,因此在分页查找时,需要进行嵌套查询. select sal,ename from (select rownum as ...
- The Accumulation of Capital
The Accumulation of Capital ---- by *Adam Smith Capitals are increased by parsimony, and diminished ...
- PHP中使用正则表达式详解 preg_match() preg_replace() preg_mat
PHP中嵌入正则表达式常用的函数有四个: 1.preg_match() :preg_match() 函数用于进行正则表达式匹配,成功返回 1 ,否则返回 0 . 语法:int preg_match( ...
- Entity Framework 学习初级篇4--Entity SQL
Entity SQL 是 ADO.NET 实体框架 提供的 SQL 类语言,用于支持 实体数据模型 (EDM).Entity SQL 可用于对象查询和使用 EntityClient 提供程序执行的查询 ...
- 【转】Build Your own Simplified AngularJS in 200 Lines of JavaScript
原文:http://blog.mgechev.com/2015/03/09/build-learn-your-own-light-lightweight-angularjs/ Build Your o ...
- How to spend you day ?
如果这是你生命中的最后的一天,你该如何去过好它呢? 不要浪费你生命中的每一分,每一秒!!!
- jdb 调试
C:\Users\Reverse>adb shell am start -D -n lwf.lc.pncdd/lwf.lc.pncdd.MainC 查看内存情况: cat /proc/N/map ...
- Kali-linux安装之后的简单设置(转)
1.更新软件源: 先备份软件源文件 cp /etc/apt/sources.list /etc/apt/sources.list.bak 修改sources.list文件: leafpad /etc/ ...