Bo's blog

Wednesday, March 10, 2010

Caused by: java.net.UnknownHostException:

 

If you pass in an IP address but has some prefix spaces before IP address or hostname, will cause the exception

Caused by: java.net.UnknownHostException: 

but the suffix spaces are okay.

@Test
public void testIP () throws UnknownHostException
{
  InetAddress ia = InetAddress.getByName (" 10.48.131.98");
  System.out.printf ("IP: %s %n", ia);
}

@Test
public void testIP () throws UnknownHostException
{
  InetAddress ia = InetAddress.getByName ("www.yahoo.com ");
  System.out.printf ("IP: %s %n", ia);
}

0 Comments:

Post a Comment

<< Home