Mercurial > hg > y16 > e165714 > os > 7.2
changeset 0:75c3caab3ad7 default tip
getaddinfo
author | Higashi Yonamine <e165714@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Feb 2018 14:48:26 +0900 |
parents | |
children | |
files | Java/getaddinfo.java |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Java/getaddinfo.java Fri Feb 02 14:48:26 2018 +0900 @@ -0,0 +1,16 @@ +import java.net.*; + +public class getaddinfo{ + public static void main (String[] args) { + try { + InetAddress host = InetAddress.getLocalHost(); + String hostname = host.getHostName(); + InetAddress[] IPAddress = InetAddress.getAllByName(hostname); + for (InetAddress address : IPAddress){ + System.out.println("Use address:" + address); + } + } catch(UnknownHostException e){ + System.out.println(e); + } + } +}