Java -- 网络编程
2013-11-06 21:46
197 查看
1. 地址获取 和 编码解码
public class Net { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub InetAddress ip = InetAddress.getByName("127.0.0.1"); System.out.println("send msg is " + ip.isReachable(5000)); System.out.println("HostAdd " + ip.getHostAddress() + "HostName " + ip.getHostName() ); InetAddress local = InetAddress.getByAddress(new byte[]{127,0,0,1}); System.out.println("send msg is " + local.isReachable(5000)); System.out.println("HostAdd " + local.getHostAddress() + "HostName " + local.getHostName() ); //编码 String urlStr = URLEncoder.encode("向杰","GBK"); System.out.println(urlStr); //解码 String keyWord = URLDecoder.decode("%E5%90%91%E6%9D%B0","UTF-8"); System.out.println(keyWord); } }
相关文章推荐
- java理论之java多线程与网络编程
- Java的网络编程
- java网络编程的具体学习方向
- Java 网络编程(六) 使用无连接的数据报(UDP)进行通信
- Java 网络IO编程总结(BIO、NIO、AIO均含完整实例代码)
- 解决java网络编程IPv6问题
- Java的网络编程初识
- Java网络编程从入门到精通(17):Socket类的getter和setter方法(1)
- 【Java笔记】网络编程
- Java的网络编程解析
- java网络编程二
- JAVA网络编程之获取网络资源
- java网络编程中Socket什么意思?怎么工作的?
- java网络编程之socket
- java网络编程
- java 网络编程之Socket详解
- java基础学习总结——网络编程
- Java 网络编程简单学习2
- JAVA网络编程之模拟表单提交
- java网络编程