1、NIO包中的 *** 作
String content = new String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource("static/xxxx.txt").toURI())), "utf-8");
2、ClassPathResource 读取 inputstream
ClassPathResource classPathResource = new ClassPathResource("static/xxx.txt"); InputStream inputStream = classPathResource.getStream(); int fileLength = (int) classPathResource.getFile().length(); byte b[] = new byte[fileLength]; inputStream.read(b); inputStream.close(); String str = new String(b, "utf-8");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)