nyla.solutions.global.net.Networking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.global Show documentation
Show all versions of nyla.solutions.global Show documentation
Nyla Solutions Global Java API provides support for basic application
utilities (application configuration, data encryption, debugger and text
processing).
The newest version!
package nyla.solutions.global.net;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* Utility for network related tasks
* @author Gregory Green
*
*/
public final class Networking
{
/**
* @return if two host names are equal by IP addresses or host name
*/
public static boolean hostEquals(String host1, String host2)
{
if(host1 == null)
return false;
if(host1.equalsIgnoreCase(host2))
return true;
if(host2 == null)
return false;
try
{
//check ip address host 1
InetAddress[] addresses1 = InetAddress.getAllByName(host1);
InetAddress address1 = null;
InetAddress[] addresses2 = InetAddress.getAllByName(host2);
InetAddress address2 = null;
if(addresses1 != null)
{
for (int i=0; i