public static String readClasspathFile(String fullPath) throws IOException {
        StringBuilder sb = new StringBuilder();
        try (
                InputStreamReader reader = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(fullPath));
                BufferedReader br = new BufferedReader(reader)
        ) {
            br.lines().forEach(line -> sb.append(line).append(System.lineSeparator()));
        }
        return sb.toString().replaceAll(BOM, "");
    }
public static String readClasspathFile ( String fullPath ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; try ( InputStreamReader reader = new InputStreamReader ( Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( fullPath ) ) ; BufferedReader br = new BufferedReader ( reader ) ) { br . lines ( ) . forEach ( line -> sb . append ( line ) . append ( System . lineSeparator ( ) ) ) ; } return sb . toString ( ) . replaceAll ( BOM , "" ) ; }
@param fullPath classpath路径
@return 读取classpath中的资源文件, 得到完整内容,注意:它会去除文件开头的BOM特殊字符.
@throws IOException