InetAddressTest
来源:互联网 发布:济南用友软件代理商 编辑:程序博客网 时间:2024/06/11 08:37
package test.socket;import java.net.InetAddress;import java.net.UnknownHostException;/** * @author Administrator * Internet 地址获取 * */public class InetAddressTest {public static void main(String[] args) {if(args.length>0){String host=args[0];try {InetAddress[] inetAddresss=InetAddress.getAllByName(host);for(InetAddress a:inetAddresss){System.out.println("远端地址:"+a);}} catch (UnknownHostException e) {e.printStackTrace();}}else{try {InetAddress inetAddress=InetAddress.getLocalHost();System.out.println("主机名/主机地址:"+inetAddress);System.out.println("本机地址:"+inetAddress.getHostAddress());System.out.println("主机名:"+inetAddress.getHostName());} catch (UnknownHostException e) {e.printStackTrace();}}}}
0 0
- InetAddressTest
- InetAddressTest
- org.apache.harmony.tests.java.net.InetAddressTest#test_isReachableLjava_net_NetworkInterfaceII 分析
- 在WinCE5.0和WinCE6.0下,编译选项介绍
- Qt中文乱码解决方法
- 第一次android小组会
- 深入理解.bin文件和.nb0文件的结构
- Flex 操作XML
- InetAddressTest
- WINCE驱动程序快速入门
- 菜鸟学Python之面向对象
- Android Button实现功能的三种方法
- socket客户端test
- Windows静态库和动态库的创建和使用 (lib vs dll)
- 图解WinCE6.0下的内核驱动和用户驱动
- 单调队列
- poj 1041 John's trip (边最小字典序欧拉路径 Fleury)