Display System IP Address Using Passing Host Names

/*This program you can pass the Host Names Array and you will get that Particular system IP Address
* @Author – Ashoka Bhat
*/

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;

public class HostIpAddressFinder {

public static void main(String[] args)throws IOException {

try{
String[] hostList= {“SYSTEM-LT-0162″,”SYSTEM-DT-0128″,”SYSTEM-DT-0079”};
for(int counter=0;counter 0)
responseIpAddress = addr[0].getHostAddress();

for(int iter=1;iter<addressLength;++iter)
{
responseIpAddress += ",";
responseIpAddress += addr[iter].getHostAddress();
}
/*if(responseIpAddress.contains(":"))
{
int lastInd = responseIpAddress.lastIndexOf(",");
responseIpAddress = responseIpAddress.substring(0, lastInd);
}*/

}catch(Exception e)
{
System.out.println("Error : "+e );
return "";
}
return responseIpAddress;
}

}

Advertisements

About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s