0

I have been using InetAddress.getLocalHost().getHostAddress(), how would I get this as a string?

millimoose
  • 39,073
  • 9
  • 82
  • 134
Harry Hartley
  • 85
  • 1
  • 7

1 Answers1

1

To output an ip as string, from Justin Waugh's answer:

Simply call InetAddress.getByName(String host) passing in your textual IP address.

From the javadoc: The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address.

InetAddress javadoc

Or use InetAddress.getHostAddress() as Nambari suggested.

Community
  • 1
  • 1
0x6C38
  • 6,796
  • 4
  • 35
  • 47