2017-04-12 00:48
感谢楼主提供方法
我现在是这么解决
fileName = fileName.replace("classpath:/", "");
StringBuilder out = new StringBuilder();
InputStream inputStream = com.jfinal.template.FileStringSource.class.getClassLoader().getResourceAsStream(fileName);
byte[] b = new byte[4096];
try {
for (int n; (n = inputStream.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
} catch (IOException e) {
throw new RuntimeException("Error loading sql file.", e);
} finally {
if (inputStream != null) try {inputStream.close();} catch (IOException e) {LogKit.error(e.getMessage(), e);}
}
return out;