/** * 获取省份和城市,传递水晶IP地址库的路径 com.tz.util.ip 方法名:ipLocation 创建人:xuchengfei 手机号码:15074816437 * 时间:2015年9月15日-下午11:21:33 * * @param ip * @param path * @return 返回类型:String * @exception * @since 1.0.0 */ public static String ipLocation(String ip, String path) { String ipLocation = ""; TmIPSeeker ipSeeker = new TmIPSeeker("qqwry.dat", path); ipLocation = ipSeeker.getIPLocation(ip).getCountry() + " " + ipSeeker.getIPLocation(ip).getArea(); return ipLocation; }
/** * 根据IP地址找到你对应城市和省份 com.tz.util.ip 方法名:ipLocation 创建人:xuchengfei 手机号码:15074816437 * 时间:2015年9月15日-下午11:21:02 * * @param ip * @return 返回类型:String * @exception * @since 1.0.0 */ public static String ipLocation(String ip) { String ipLocation = ""; TmIPSeeker ipSeeker = new TmIPSeeker("qqwry.dat", "I:/潭州学院高级班-v2.0/项目实战/WebRoot/ip"); ipLocation = ipSeeker.getIPLocation(ip).getCountry() + " " + ipSeeker.getIPLocation(ip).getArea(); return ipLocation; }
/** * 获取省份和城市,传递水晶IP地址库的路径 com.tz.util.ip 方法名:ipLocation 创建人:xuchengfei 手机号码:15074816437 * 时间:2015年9月15日-下午11:22:05 * * @param request * @return 返回类型:String * @exception * @since 1.0.0 */ public static String ipLocation(HttpServletRequest request) { if (request == null) return ""; try { String ipLocation = ""; String ip = getIpAddress(request); String path = request.getRealPath("/") + "/ip"; if (TmStringUtils.isNotEmpty(path)) { path = TmStringUtils.conversionSpecialCharacters(path); TmIPSeeker ipSeeker = new TmIPSeeker("qqwry.dat", path); ipLocation = ipSeeker.getIPLocation(ip).getCountry() + " " + ipSeeker.getIPLocation(ip).getArea(); } return ipLocation; } catch (Exception e) { return ""; } }
/** * 找到城市 com.tz.util.ip 方法名:ipcity 创建人:xuchengfei 手机号码:15074816437 时间:2015年9月15日-下午11:21:19 * * @param ip * @return 返回类型:String * @exception * @since 1.0.0 */ public static String ipcity(String ip) { String ipLocation = ""; TmIPSeeker ipSeeker = new TmIPSeeker("qqwry.dat", "D:/tzprojects/tz_desk/WebRoot/ip"); ipLocation = ipSeeker.getIPLocation(ip).getArea(); return ipLocation; }