Which of the following is the best and most portable way to get the hostname of the current computer in Java?

Runtime.getRuntime().exec("hostname")

vs

InetAddress.getLocalHost().getHostName()

Edit
Report