Jump to content

User:MER-C/ResolveWebsite.java

From Wikipedia, the free encyclopedia
/**
 * @(#)ResolveWebsite.java 0.01 19/09/2007
 * Copyright (C) 2007 MER-C
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.net.*;

/**
 *  Prints out all IP addresses the list of specified websites are hosted on.
 *  Usage: <tt>java ResolveWebsite wikipedia.org wikimedia.org ...</tt>
*/
public class ResolveWebsite
{  
    public static void main(String[] args) throws Exception
    {  
        if (args.length > 0)
        {  
            for (int i = 0; i < args.length; i++)
            {
                InetAddress[] addresses = InetAddress.getAllByName(args[i]);
                for (int j = 0; j < addresses.length; j++)
    	           System.out.println(addresses[j]);
    	    }
         }
         else
            System.out.println("Domain(s) not specified!");
    }
}