`
zsnlovewl
  • 浏览: 173198 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java实现whois域名查询

    博客分类:
  • JAVA
阅读更多
import java.net.*;
import java.io.*;
public class whois {
public final static int DEFAULT_PORT = 43;
public final static String DEFAULT_HOST = "whois.cnnic.net.cn";// cn接口:"whois.cnnic.net.cn" com接口:"whois.internic.net"
public static void main(String[] args) {
InetAddress server;
int port = DEFAULT_PORT;
String str = "";
try {
server = InetAddress.getByName(DEFAULT_HOST);
} catch (Exception e) {
e.printStackTrace();
return;
}
try {
Socket theSocket = new Socket(server, port);
Writer out = new OutputStreamWriter(theSocket.getOutputStream(),
"UTF-8");
out.write("9981a.cn \r\n");
out.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(
theSocket.getInputStream(), "UTF-8"));
while ((str = br.readLine()) != null)
System.out.println(str);
} catch (IOException e) {
e.printStackTrace();
}
}
} <!--v:3.2-->
分享到:
评论
1 楼 dupeng41255 2015-01-09  
问一下,。com的接口 是不是需要注册啊?我调用的时候返回说需要注册谢谢

相关推荐

Global site tag (gtag.js) - Google Analytics