java实现whois域名查询

xiaoxiao2025-02-10  16

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--> 相关资源:Java实现简单whois查询
转载请注明原文地址: https://www.6miu.com/read-5024407.html

最新回复(0)