spring 读取资源文件为字符串的方式

获取资源文件转为字节数组来读取

1
String sqlSb = new String(FileCopyUtils.copyToByteArray(new ClassPathResource(sqlFile).getFile()),StandardCharsets.UTF_8);

资源文件转为流来读取

1
String sqlSb = StreamUtils.copyToString(new ClassPathResource(sqlFile).getInputStream(),StandardCharsets.UTF_8);