/*import java.net.*;
public class ShowIP
{
public static void main(String[] args)
{
try
{
InetAddress ad = InetAddress.getLocalHost();
int h = ad.hashCode();
String c = ad.getCanonicalHostName();
String a = ad.getHostAddress();
String n = ad.getHostName();
System.out.println (ad.getHostAddress());
System.out.println (ad.getHostName());
System.out.println ("home-7077aa2ac2" + "'s IP is "+ad.getHostAddress());
System.out.println (ad +"" +h +""+c +"\n" +a +"" +n);
}
catch (UnknownHostException ex)
{
System.out.println (ex);
}
}
}
class pwd {
public static void main(String[] args) {
String curDir = System.getProperty("user.dir");
System.out.println (curDir);
}
}*/
import java.net.InetAddress;
class ShowIP
{
public static void main(String[] args)
{
try
{
InetAddress ad;
ad = InetAddress.getByName("home-7077aa2ac2");
System.out.println (ad);
ad = InetAddress.getLocalHost();
System.out.println (ad);
System.out.println ("\n\n");
System.out.println (ad.getAddress()+"\n"+ad.getCanonicalHostName()+"\n"+
ad.getHostAddress()+"\n"+ad.getHostName()+"\n"+
ad.getLocalHost()+"\n"+ad.isMulticastAddress()+"\n"+
ad.toString());
byte [] b;
b = ad.getAddress();
System.out.println (b);
String str ="";
for (int i = 0; i<b.length; i++)
{
if (i>0)
{
str += ".";
}
str += b[i];
}
System.out.println (str);
}
catch (Exception ex)
{
System.out.println (ex);
}
}
}
public class ShowIP
{
public static void main(String[] args)
{
try
{
InetAddress ad = InetAddress.getLocalHost();
int h = ad.hashCode();
String c = ad.getCanonicalHostName();
String a = ad.getHostAddress();
String n = ad.getHostName();
System.out.println (ad.getHostAddress());
System.out.println (ad.getHostName());
System.out.println ("home-7077aa2ac2" + "'s IP is "+ad.getHostAddress());
System.out.println (ad +"" +h +""+c +"\n" +a +"" +n);
}
catch (UnknownHostException ex)
{
System.out.println (ex);
}
}
}
class pwd {
public static void main(String[] args) {
String curDir = System.getProperty("user.dir");
System.out.println (curDir);
}
}*/
import java.net.InetAddress;
class ShowIP
{
public static void main(String[] args)
{
try
{
InetAddress ad;
ad = InetAddress.getByName("home-7077aa2ac2");
System.out.println (ad);
ad = InetAddress.getLocalHost();
System.out.println (ad);
System.out.println ("\n\n");
System.out.println (ad.getAddress()+"\n"+ad.getCanonicalHostName()+"\n"+
ad.getHostAddress()+"\n"+ad.getHostName()+"\n"+
ad.getLocalHost()+"\n"+ad.isMulticastAddress()+"\n"+
ad.toString());
byte [] b;
b = ad.getAddress();
System.out.println (b);
String str ="";
for (int i = 0; i<b.length; i++)
{
if (i>0)
{
str += ".";
}
str += b[i];
}
System.out.println (str);
}
catch (Exception ex)
{
System.out.println (ex);
}
}
}
No comments:
Post a Comment