Java Example Program / Sample Source Code
import java.awt.*;
import java.applet.*;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class ShowIPAddress extends Applet {
public void paint(Graphics g) {
try {
String ip = new Socket(getDocumentBase().getHost(),
getDocumentBase().getPort()).getLocalAddress()
.getHostAddress();
g.drawString(ip, 25, 25);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} |
|
|