ip截取及处理

String info = rs.getString(“ip_end”);

            String[] names = info.split("\\.");
            String ip = "";
            for (String s : names) {
                int d = 0;
                if (!s.equals("000")) {
                    d = Integer.parseInt(s);
                }
                if (ip.length() == 0) {
                    ip += String.valueOf(Integer.valueOf(s));
                } else {
                    ip += "." + String.valueOf(Integer.valueOf(s));
                }
            }

更新库里字段
String sql = “update ip_location set province = '”

                        + str_region + "', city = '" + str_city
                        + "', county = '" + str_county
                        + "'where ip_end = '" + info + "'";

你可能感兴趣的:(ip截取及处理)