打包套接字测试; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import Java.io.input streamreader; import Java.net.inet地址; import java.net.URL; import java.net.URLConnection; publicclassipdemo { publicstaticvoidmain (字符串[ ] args ) { try { String ip1=getMyIP ); system.out.println(myIP: ) IP1 ); string ip2=获取我的IP local (; system.out.println (my localip : ) IP2 ); }catch(ioexceptionE1) { E1 .打印堆栈跟踪); }隐私保护策略(throwsioexception (inputstream ins=null; try{URLURL=newURL(http://IP.cn ); urlconnectioncon=URL.open connection (; ins=con.getInputStream (; inputstreamreaderisreader=newinputstreamreader (ins,' utf-8 '; bufferedreaderbreader=newbufferedreader (is reader; string buffer web内容=new string buffer (; 字符串str=null; while((str=breader.readline ) )!=null(webcontent.append ) ) str; } int start=webContent.indexOf (' ' ) 6; int end=webContent.indexOf ('