File file = ResourceUtils.getFile("classpath:face/1112.txt");
InputStream inputStream = new FileInputStream(file);
InputStreamReader treader =
new InputStreamReader(inputStream);
BufferedReader tBff = new BufferedReader(treader);
String FileReaderstr = tBff.readLine();
tBff.close();
ResourceUril读取了文件地址 ,字符流读取到文件数据
----------------------------------------------------------------------------------------------------------------------------
上面这种在idea上可以但是放到服务器上会失效
下面这种才是干货:
ClassPathResource classPathResource = new ClassPathResource("face/1112.txt");
InputStream inputStream = classPathResource.getInputStream();
InputStreamReader treader =
new InputStreamReader(inputStream);
BufferedReader tBff = new BufferedReader(treader);
String FileReaderstr = tBff.readLine();
tBff.close();