【解决方案】springboot 打jar包后启动,resource下配置文件找不到
程序员文章站
2022-05-04 17:30:54
...
public static String getFileContent(String fileName) {
StringBuilder sb = new StringBuilder();
try {
ClassPathResource classPathResource = new ClassPathResource(fileName);
InputStream stream = classPathResource.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8.name()));
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} catch (Exception e) {
return sb.toString();
}
}
上一篇: java 线程