33 lines
1.2 KiB
Java
33 lines
1.2 KiB
Java
package praktikum5.aufgabe1;
|
|
|
|
import java.net.UnknownHostException;
|
|
import java.net.InetAddress;
|
|
|
|
public class InternetAdresse {
|
|
public static void main( String args[] ) {
|
|
try {
|
|
InetAddress iaddr1 = InetAddress.getByName("www.fh-dortmund.de");
|
|
InetAddress iaddr2 = InetAddress.getLocalHost();
|
|
InetAddress iaddr3 = InetAddress.getByName("localhost");
|
|
System.out.println(iaddr1.getHostName() + ": " + iaddr1.getHostAddress());
|
|
System.out.println(iaddr2.getHostName() + ": " + iaddr2.getHostAddress());
|
|
System.out.println(iaddr3.getHostName() + ": " + iaddr3.getHostAddress());
|
|
System.out.println();
|
|
|
|
byte[] ip = iaddr3.getAddress();
|
|
for(int i = 0; i < ip.length; i++) {
|
|
System.out.println(i + ": " + ip[i]);
|
|
}
|
|
System.out.println();
|
|
|
|
InetAddress[] iaddr4 = InetAddress.getAllByName("www.adeso.de");
|
|
for (int i = 0; i < iaddr4.length; i++) {
|
|
System.out.println(i + ": " + iaddr4[i].getHostName() + ": " + iaddr4[i].getHostAddress());
|
|
}
|
|
}
|
|
catch (UnknownHostException e) {
|
|
System.out.println( "Host nicht bekannt" );
|
|
}
|
|
}
|
|
}
|