In this section we cover and explain Find the IPAddress of Local Host
| previous | Home | Next |
import java.net.*;
class IPAddress {
public static void main (String args[]) {
try {
InetAddress Computer = InetAddress.getLocalHost();
byte[] address = Computer.getAddress();
System.out.print("hello ");
for (int i = 0; i < address.length; i++) {
int unsignedByte = address[i] < 0 ? address[i] + 256 : address[i];
System.out.print(unsignedByte + ".");
}
System.out.println();
}
catch (UnknownHostException e) {
System.out.println("hi");
}
}
}
| previous | Home | Next |