IDEA 获取 resources 下的文件

FLowUs邀请链接:https://flowus.cn/login?code=AXNU63
FlowUs邀请码:AXNU63


URL resource01 = MainMobile.class.getResource("");
URL resource02 = MainMobile.class.getResource("/conf.properties");//success: resources下的

InputStream ip3 = MainMobile.class.getClassLoader().getResourceAsStream("conf.properties");//success: resources下的
InputStream resource32 = Thread.currentThread().getContextClassLoader().getResourceAsStream("conf.properties");

InputStream ips =  MainMobile.class.getResourceAsStream("/conf.properties");//success: resources下的
URL resource13 = Thread.currentThread().getContextClassLoader().getResource("conf.properties");
InputStream resource43 = Thread.currentThread().getContextClassLoader().getResourceAsStream("conf.properties");
InputStream resource23 = Thread.currentThread().getContextClassLoader().getResourceAsStream("conf.properties");

注意 properties的第一行不要有空格

posted @ 2020-03-23 18:11  wbytts  阅读(684)  评论(0编辑  收藏  举报