展开全部
参考一下,遍历所62616964757a686964616fe59b9ee7ad9431333363393062有IP的:public static Object[] GET_IP_ARR(String ipfrom, String ipto) {
ArrayList ips = new ArrayList();
String[] ipfromd = ipfrom.split("\\.");
String[] iptod = ipto.split("\\.");
int[] int_ipf = new int[4];
int[] int_ipt = new int[4];
for (int i = 0; i
int_ipf[i] = Integer.parseInt(ipfromd[i]);
int_ipt[i] = Integer.parseInt(iptod[i]);
}
for (int A = int_ipf[0]; A <= int_ipt[0]; A++) {
for (int B = (A == int_ipf[0] ? int_ipf[1] : 0); B <= (A == int_ipt[0] ? int_ipt[1]
: 255); B++) {
for (int C = (B == int_ipf[1] ? int_ipf[2] : 0); C <= (B == int_ipt[1] ? int_ipt[2]
: 255); C++) {
for (int D = (C == int_ipf[2] ? int_ipf[3] : 0); D <= (C == int_ipt[2] ? int_ipt[3]
: 255); D++) {
ips.add(new String(A + "." + B + "." + C + "." + D));
}
}
}
}
return ips.toArray();
}