package ipconfig;

 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection; public class gainInformation {
public static void main(String args[]) {
String publicip = getip.publicip();
int ipindex1 = publicip.indexOf("[");
int ipindex2 = publicip.indexOf("]");
String ip = publicip.substring(ipindex1+1, ipindex2);
System.out.println(ip);
int address1 = publicip.indexOf("来自:");
int address2 = publicip.indexOf("</center>");
String substring = publicip.substring(address1+3,address2);
String[] split = substring.split(" ");
for (int i = 0; i < split.length; i++) {
System.out.println(split[i]);
}
}
}
class getip{
public static String publicip() {
BufferedReader br = null;
try {
URL url = new URL("http://20019.ip138.com/ic.asp");
URLConnection urlconn = url.openConnection();
br = new BufferedReader(new InputStreamReader(urlconn.getInputStream()));
String buf,get = null;
while ((buf = br.readLine()) != null) {
get+=buf;
}
return get;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}

java获取公网ip以及物理地址和代理商的更多相关文章

  1. JAVA获取公网ip

    在ipv4地址稀缺的今天,分配到公网ip几乎是不可能的,但是我拨号之后的ip竟然是公网IP. 将自己的电脑作为服务器·,做点好玩的程序,就成为了可能. 由于运营商的ip是动态分配的公网ip的所以就需要 ...

  2. C#联机获取公网IP

    C#获取IP的方式有很多种,这里通过http://www.ipip.net/这个稳定的在线IP库的来获取公网IP. string tempip = "0.0.0.0"; WebRe ...

  3. python获取公网ip,本地ip及所在国家城市等相关信息收藏

    python获取公网ip的几种方式       from urllib2 import urlopen   my_ip = urlopen('http://ip.42.pl/raw').read() ...

  4. Python 之自动获取公网IP

    Python 之自动获取公网IP 2017年9月30日 文档下载:https://wenku.baidu.com/view/ff40aef7f021dd36a32d7375a417866fb84ac0 ...

  5. Delphi获取公网IP地址函数

    uses IdHTTP; function GetPublicIP: string; var strIP, URL: string; iStart, iEnd: Integer; MyIdHTTP: ...

  6. 获取本地ip和获取公网ip

    import socket def get_local_ip(): ''' 获取本地ip地址 :return: ''' s = socket.socket(socket.AF_INET, socket ...

  7. python获取公网ip的几种方式

    python获取公网ip的几种方式 转 https://blog.csdn.net/conquerwave/article/details/77666226 from urllib2 import u ...

  8. Java获取用户ip

    /** * 获取客户端ip地址(可以穿透代理) * * @param request * @return */ public static String getRemoteAddr(HttpServl ...

  9. java获取服务器IP地址及MAC地址的方法

    这篇文章主要介绍了java编程实现获取机器IP地址及MAC地址的方法,实例分析了Java分别针对单网卡及多网卡的情况下获取服务器IP地址与MAC地址的相关技巧,需要的朋友可以参考下   本文实例讲述了 ...

随机推荐

  1. 轻量级批量Omnitty工具安装和简单使用

    一.Omnitty简单介绍 在实际工作需要同时对多台docker进行批量处理,为了节省时间,这个运维轻量级工具解决此问题 二.Omnitty简单按照 下载需要安装包和依赖包: omnitty-0.3. ...

  2. IDEA 使用方法快捷键

    Ctrl+Shift + Enter,语句完成“!”,否定完成,输入表达式时按 “!”键Ctrl+E,最近的文件Ctrl+Shift+E,最近更改的文件Shift+Click,可以关闭文件Ctrl+[ ...

  3. JDK各版本内容和新特性

    JDK各版本内容和新特性 - yanlzhl - 博客园 https://www.cnblogs.com/yanlzhl/articles/5694470.html    版本JDK1.0:1995年 ...

  4. TCP Operational Overview and the TCP Finite State Machine (FSM) http://tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF.htm

    http://tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF.htm   http://tcpipgu ...

  5. Deep Learning 28:读论文“Multi Column Deep Neural Network for Traffic Sign Classification”-------MCDNN 简单理解

    读这篇论文“ Multi Column Deep Neural Network for Traffic Sign Classification”是为了更加理解,论文“Multi-column Deep ...

  6. caution

    做好需求更改的准备,提高代码的扩展性和可维护性:预留出修改bug和需求的时间:对需求理解透彻再开始写代码:代码不要写死,防止需求变动. 

  7. UESTC 982质因子分解

    读入一个自然数,将nn分解为质因子连乘的形式输出. Input 有多组测试数据.输入的第一行是整数TT(0<T≤10000),表示测试数据的组数.每一组测试数据只有一行,包含待分解的自然数nn. ...

  8. 疯狂JAVA——数组

    java是静态语言,java数组也是静态语言 静态初始化: String[] a = new String[]{ "我"}; String[] b = { "你" ...

  9. Watir: Get document detail information in Watir.

    ie.#{element}(:id,"foo").document.currentstyle.attributeAsCamelCase so ie.#{element}(:id,& ...

  10. 云-腾讯云:视频解决方案-un

    ylbtech-云-腾讯云:视频解决方案 一站式视频解决方案,包含直播.点播.互动直播.云通信等产品:发布网络覆盖全球.海量转码设备.数十年深厚音视频技术积淀. 1.返回顶部   2.返回顶部   3 ...