if (localIp == null) {
try {
Properties props = new Properties();
String path = SystemService.class.getResource("/config/cbp.properties").getFile();
InputStream in = new BufferedInputStream(new FileInputStream(path));
props.load(in);
localIp = props.getProperty("local.ip");
} catch (Exception e) {
ExceptionHolder exceptionHolder = new ExceptionHolder(e);
logger.error(exceptionHolder.getExceptionStack());
}
}
return localIp;
}
修改为:
public static String getLocalIp() {
if (localIp == null) {
try {
Properties props = new Properties();
String path = SystemService.class.getResource("/config/cbp.properties").getFile();
try {
path = java.net.URLDecoder.decode(path, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
InputStream in = new BufferedInputStream(new FileInputStream(path));
props.load(in);
localIp = props.getProperty("local.ip");
} catch (Exception e) {
ExceptionHolder exceptionHolder = new ExceptionHolder(e);
logger.error(exceptionHolder.getExceptionStack());
}
}
return localIp;
}