¿ìËÙÒµÎñͨµÀ

JavaÍøÂç±à³Ì´ÓÈëÃŵ½¾«Í¨£¨2£©£º´´½¨InetAddress¶ÔÏóµÄËĸö¾²Ì¬·½·¨ - ±à³ÌÈëÃÅÍø

×÷Õß ØýÃû¼¼Êõ À´Ô´ NET±à³Ì ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-21
½á¹û£º

ComputerName/192.168.18.10

²âÊÔ3£º´ú±í±¾»úµÄlocalhost

Ö´ÐÐÈçÏÂÃüÁ

java inet.MyInetAddress2 localhost

ÔËÐнá¹û£º

localhost/127.0.0.1

JavaÍøÂç±à³Ì´ÓÈëÃŵ½¾«Í¨£¨2£©£º´´½¨InetAddress¶ÔÏóµÄËĸö¾²Ì¬·½·¨(3)

ʱ¼ä:2011-01-12

¶ÔÓÚ±¾»úÀ´Ëµ£¬³ýÁË¿ÉÒÔʹÓñ¾»úÃû»òlocalhostÍ⣬»¹¿ÉÒÔÔÚhostsÎļþÖжԱ¾»ú×ö“IP/ÓòÃû”Ó³É䣨ÔÚWindows²Ù×÷ϵͳÏ£©¡£Õâ¸öÎļþÔÚC:\WINDOWS\system32\drivers\etcÖС£´ò¿ªÕâÁ½¸öÎļþÖУ¬ÔÚ×îºó¼ÓÒ»ÐÐÈçÏÂËùʾµÄ×Ö·û´®£º

192.168.18.100¡¡¡¡ www.mysite.com

²âÊÔ4£º±¾»úÓòÃûwww.mysite.com

Ö´ÐÐÈçÏÂÃüÁ

java inet.MyInetAddress2 www.mysite.com

ÔËÐнá¹û£º

www.mysite.com/192.168.18.100

getByName·½·¨³ýÁË¿ÉÒÔʹÓÃÓòÃû×÷Ϊ²ÎÊýÍ⣬Ҳ¿ÉÒÔÖ±½ÓʹÓÃIPµØÖ·×÷Ϊ²ÎÊý¡£Èç¹ûʹÓÃIPµØÖ·×÷Ϊ²ÎÊý£¬Êä³öInetAddress¶ÔÏóʱÓòÃûΪ¿Õ£¨³ý·Çµ÷ÓÃgetHostName·½·¨ºó£¬ÔÙÊä³öInetAddress¶ÔÏó¡£getHostName·½·¨½«ÔÚÏÂÃæµÄÄÚÈݽéÉÜ£©¡£¶ÁÕß¿ÉÒÔʹÓÃ129.42.58.212×÷ΪMyInetAddress2µÄÃüÁîÐвÎÊý£¨ÕâÊÇwww.ibm.comµÄIP£©£¬¿´¿´»áµÃµ½Ê²Ã´½á¹û¡£

Èý¡¢getAllByName·½·¨

ʹÓÃgetAllByName·½·¨¿ÉÒÔ´ÓDNSÉϵõ½ÓòÃû¶ÔÓ¦µÄËùÓе**P¡£Õâ¸ö·½·¨·µ»ØÒ»¸öInetAddressÀàÐ͵ÄÊý×é¡£Õâ¸ö·½·¨µÄ¶¨ÒåÈçÏ£º

public static InetAddress[] getAllByName(String host) throws UnknownHostException

ÓëgetByName·½·¨Ò»Ñù£¬µ±host²»´æÔÚʱ£¬getAllByNameÒ²»áÅ׳öUnknowHostExceptionÒì³££¬getAllByNameÒ²²»»áÑéÖ¤IPµØÖ·ÊÇ·ñ´æÔÚ¡£ÏÂÃæµÄ´úÂëÑÝʾÁËgetAllByNameµÄÓ÷¨£º

package inet; ¡¡ import java.net.*; ¡¡ public class MyInetAddress3 ¡¡ { ¡¡¡¡¡¡¡¡¡¡ public static void main(String[] args) throws Exception ¡¡¡¡¡¡¡¡¡¡ { ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if (args.length == 0) ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return; ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ String host = args[0]; ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ InetAddress addresses[] = InetAddress.getAllByName(host); ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ for (InetAddress address : addresses) ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ System.out.println(address); ¡¡¡¡¡¡¡¡¡¡ } ¡¡ }

²âÊÔ1£ºÔ¶³ÌÖ÷»úwww.csdn.net

Ö´ÐÐÈçÏÂÃüÁ

java inet.MyInetAddress3 www.csdn.net

ÔËÐнá¹û£º

www.csdn.net/211.100.26.124 www.csdn.net/211.100.26.121 www.csdn.net/211.100.26.122 www.csdn.net/211.100.26.123

JavaÍøÂç±à³Ì´ÓÈëÃŵ½¾«Í¨£¨2£©£º´´½¨InetAddress¶ÔÏóµÄËĸö¾²Ì¬·½·¨(4)

ʱ¼ä:2011-01-12

½«ÉÏÃæµÄÔËÐнá¹ûºÍÀý³Ì3-2µÄ²âÊÔ1µÄÔËÐнá¹û½øÐбȽϣ¬¿ÉÒԵóöÒ»¸ö½áÂÛ£¬getByName·½·¨·µ»Øµ**PµØÖ·¾ÍÊÇgetAllByName·½·¨·µ»ØµÄµÚÒ»¸öIPµØÖ·¡£ÊÂʵÉÏ£¬getByNameµÄÈ·ÊÇÕâÑùʵÏֵģ¬getByNameµÄʵÏÖ´úÂëÈçÏ£º

public static InetAddress getByName(String host) throws UnknownHostException { ¡¡¡¡¡¡¡¡ return InetAddress.getAllByName(host)[0]; }

²âÊÔ2£ºÊ¹ÓÃwww.csdn.netµÄÒ»¸öIP¡¡

Ö´ÐÐÈçÏÂÃüÁ

java inet.MyInetAddress3 211.100.26.122

ÔËÐнá¹û£º

/211.100.26.122

ËÄ¡¢getByAddress·½·¨

Õâ¸ö·½·¨±ØÐëͨ¹ýIPµØÖ·À´´´½¨InetAddress¶ÔÏ󣬶øÇÒIPµØÖ·±ØÐëÊÇbyteÊý×éÐÎʽ¡£getByAddress·½·¨ÓÐÁ½¸öÖØÔØÐÎʽ£¬¶¨ÒåÈçÏ£º

public static InetAddress getByAddress(byte[] addr) throws UnknownHostException public static InetAddress getByAddress(String host, byte[] addr) throws UnknownHostException

µÚÒ»¸öÖØÔØÐÎʽֻÐèÒª´«µÝbyteÊý×éÐÎʽµÄIPµØÖ·£¬getByAddress·½·¨²¢²»ÑéÖ¤Õâ¸öIPµØÖ·ÊÇ·ñ´æÔÚ£¬Ö»ÊǼòµ¥µØ´´½¨Ò»¸öInetAddress¶ÔÏó¡£addrÊý×éµÄ³¤¶È±ØÐëÊÇ4£¨IPv

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ