怎么可能老是出错?
这是我写一个程序,看看哪里出错了,我总是找不出错误。thxpackage net;
import java.net.*;
public class IPAddressSeek
{
public IPAddressSeek()
{
super();
}
public static void main(String[] args)
{
InetAddress hostAddress;
byte[] integer_address;
if (args.length==0)
{
try
{
hostAddress=InetAddress.getLocalHost();
integer_address=hostAddress.getAddress();
System.out.println("The domain name of localhost is:\n\t\t\t"+hostAddress.getHostname());
System.out.println("The IPAddress of localHost in the form of standardDot is:\n\t\t\t"+hostAddress.getHostAddress());
System.out.println("The IPaddress of localhost in the form of 4_integer_byte is:\n\t\t\t"+integer_address[0]+"\t"+integer_address[1]+"\t"+integer_address[2]+"\t"+integer_address[3]);
}catch(UnknowHostException e)
{e.printStackTrace();}
}else
{
try
{
hostAddress=InetAddress.getByName(args[0]);
integer_address=hostAddress.getAddress();
System.out.println("The domain name of localhost is:\n\t\t\t"+hostAddress.getHostname());
System.out.println("The IPAddress of localHost in the form of standardDot is:\n\t\t\t"+hostAddress.getHostAddress());
System.out.println("The IPaddress of localhost in the form of 4_integer_byte is:\n\t\t\t"+ integer_address[0]+"\t"+integer_address[1]+"\t"+ integer_address[2]+"\t"+integer_address[3]);
}catch(UnknowHostException e)
{e.printStackTrace();}
}
}
}