Spring boot 读取jar包中resources下的文件

String fileName = "classpath:/area.txt";
ResourceLoader resourceLoader = new DefaultResourceLoader();
InputStream is = resourceLoader.getResource(fileName).getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is,"UTF-8"));
String s="";
while((s=br.readLine())!=null)
    System.out.println(s);

你可能感兴趣的:(javaee)