【Java】从域名得到ip

package sdfg;

import java.net.InetAddress;
//import java.net.UnknownHostException;
import java.io.*;

public class sdfg {
    public static void main(String[] args) throws IOException 
    {
        
        String domain="www.google.com";
        FileWriter fw=new FileWriter("add.txt");
        
        InetAddress[] arr=InetAddress.getAllByName(domain);
        
        for(int i=0;i)
        {
            System.out.println(arr[i]);
            fw.write(arr[i].toString()+'\n');        
        }        
        
        fw.close();
        System.out.println("end");
    }
}

 

转载于:https://www.cnblogs.com/tiandsp/p/7467829.html

你可能感兴趣的:(【Java】从域名得到ip)