Sep
30
|
Use the InetAddress class.
InetAddress address = InetAddress.getLocalHost(); byte[] ip = address.getAddress(); // to get a string representation use // the getHostAddress() method String ipString = address.getHostAddress(); // for a string representation in // form hostname/literal IP address // use the toString() method String hostAndIp = address.toString();
Leave a Reply
You must be logged in to post a comment.