2727import org .slf4j .Logger ;
2828import org .slf4j .LoggerFactory ;
2929import org .springframework .core .io .ClassPathResource ;
30-
3130import javax .servlet .http .HttpServletRequest ;
3231import java .io .File ;
3332import java .io .FileNotFoundException ;
34-
3533import java .net .InetAddress ;
3634import java .net .UnknownHostException ;
3735import java .util .Calendar ;
4240 * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
4341 */
4442public class StringUtils extends org .apache .commons .lang3 .StringUtils {
43+
4544 private static final Logger log = LoggerFactory .getLogger (StringUtils .class );
4645 private static boolean ipLocal = false ;
4746 private static DbSearcher searcher = null ;
@@ -50,20 +49,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
5049 SpringContextHolder .addCallBacks (() -> {
5150 StringUtils .ipLocal = SpringContextHolder .getProperties ("ip.local-parsing" , false , Boolean .class );
5251 if (ipLocal ) {
53- /**
52+ /*
5453 * 此文件为独享 ,不必关闭
5554 */
5655 String path = "ip2region/ip2region.db" ;
5756 String name = "ip2region.db" ;
58- DbConfig config = null ;
57+ DbConfig config ;
5958 try {
6059 config = new DbConfig ();
6160 File file = FileUtil .inputStreamToFile (new ClassPathResource (path ).getInputStream (), name );
6261 searcher = new DbSearcher (config , file .getPath ());
63- } catch (DbMakerConfigException | FileNotFoundException e ) {
64- log .error (e .getMessage (), e );
65- } catch (NoSuchMethodException e ) {
66- log .error (e .getMessage (), e );
6762 } catch (Exception e ) {
6863 log .error (e .getMessage (), e );
6964 }
0 commit comments