localhost doesn't resolve to 127.0.0.1
问题 I make a call to Inet4Address.getByName("localhost") expecting to see 127.0.0.1 , but instead I see my IP assigned to my ethernet/airport. If I disconnect my ethernet/airport, I will get the resolution of 127.0.0.1 , but as soon as I connect again it resolves to the IP address of the ethernet/airport. I'm using OSX 10.6.7 and java version "1.6.0_24". My /etc/hosts file has "127.0.0.1 localhost" . Ping localhost in the terminal does resolve to 127.0.0.1. The reason I need this is that I'm