
废话少说 放码
/** * 读取Resources下资源文件 * jar包时 linux下也可用 * @param filePath 文件路径 例如 /topology/color.json 注意/ * @return String 文件内容 */privatestaticStringreadFileStreamToStr(String filePath){InputStream is=null;BufferedReader br=null;try{ is=FileReadUtils.class.getResourceAsStream(filePath);if(null== is){ log.error("readFile: file is not found, file path: {}", filePath);returnnull;} br=newBufferedReader(newInputStreamReader(is));String s;StringBuilder sb=newStringBuilder();while((s= br.readLine())!=null){ sb.append(s).append("\r\n");}return sb.toString();}catch(IOException e){ log.error(e.getCause().toString());}finally{if(is!=null){try{ is.close();}catch(IOException e){ log.error("error : FileReadUtils-readLinuxFileToStr-close InputStream : {}", e.getMessage());}}if(br!=null){try{ is.close();}catch(IOException e){ log.error("error : FileReadUtils-readLinuxFileToStr-close BufferedReader : {}", e.getMessage());}}}returnnull;}
热门文章
- 如何设计一个高效的的消息队列?_在线工具
- 基于 Apache Hudi 构建增量和无限回放事件流的 OLAP 平台
- 运城动物防疫站在哪(运城市动物疫病预防控制中心)
- 宠物粮食品牌都有什么牌子好 宠物粮食品牌都有什么牌子好的
- 宠乐康动物医院电话(宠乐康宠物医院怎么样)
- VPN Tiktok | 3月11日18M/S|免费VPN/Clash/Shadowrocket/SSR/V2ray免费节点订阅分享
- 动物园宠物店营业时间北京(北京动物园狗狗)
- 开个小型宠物食品加工厂需要多少钱费用呢视频(小型宠物食品加工厂需要多少资金)
- 猫驱虫多少钱一只(猫驱虫多少钱一次)
- VPN Tiktok | 3月31日22.4M/S|免费VPN/V2ray/SSR/Clash/Shadowrocket免费节点订阅分享