Spring中类路径下文件读取方式

InputStream is = 当前类名.class.getClassLoader().getResourceAsStream("test.properties");

InputStream is = Class.class.getResourceAsStream("/test.properties");

URL url = 当前类名.class.getClassLoader().getResource("test.properties");
        InputStream is = new FIleInputStream(new File(url.getFile()));

(需要spring相关jar):Resource resource = new ClassPathResource("test.properties");
InputStream is= resource.getInputStream()

你可能感兴趣的:(个人简介有邮箱)