I have the following code.
Properties props = new Properties();
props.load(ClassLoader.getSystemResourceAsStream("ui.properties"));
I am running a Maven build, so this file is under
src/main/resources.
When I build the file and run the application the Input Stream is null.
Any advice would be appreciated.
尝试绝对路径,例如“/ui.properties”(或文件在输出类或jar文件中的任何位置)。
can you try
props.load(getClass().getClassLoader().getResourceAsStream("ui.properties"));
instead of
props.load(ClassLoader.getSystemResourceAsStream("ui.properties"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.