|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
@ -48,26 +49,9 @@ public class CommonUtil {
|
|
|
|
|
* @return 文件内容
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static String txt2String(String path) throws IOException {
|
|
|
|
|
public static String txt2String(String path) {
|
|
|
|
|
InputStream is = CommonUtil.class.getClassLoader().getResourceAsStream(path);
|
|
|
|
|
BufferedInputStream bis = null;
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
try {
|
|
|
|
|
bis = new BufferedInputStream(is);
|
|
|
|
|
byte[] temp = new byte[1024];
|
|
|
|
|
int len;
|
|
|
|
|
while ((len = bis.read(temp)) != -1) {
|
|
|
|
|
sb.append(new String(temp, 0, len, StandardCharsets.UTF_8));
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
if (bis != null) {
|
|
|
|
|
bis.close();
|
|
|
|
|
}
|
|
|
|
|
if (is != null) {
|
|
|
|
|
is.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.toString();
|
|
|
|
|
return IoUtil.read(is, "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|