package com.npnets.readproperties;
import java.io.IOException;
import java.net.InetAddress;
public class Read {
/**
* 读取src 路径下的properties文件
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
/**
* 检查主机是否在线
*/
InetAddress address;
try {
address = InetAddress.getByName("192.168.0.33");//zq 192.168.0.114
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("Reach: " + address.isReachable(3000)); // 是否能通信 返回true或false
System.out.println(address.isReachable(3000)?0:1);
System.out.println(address.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}