比如我在com/aa/bb下放了一个resource.properties文件,在同一包下的类读取它的路径可以这样:
InputStream is = PropertiesInfo.class.getResourceAsStream("resource.properties");
但我这个类还要实现写入的功能,如何才能得到该文件的路径啊?
InputStream is = PropertiesInfo.class.getResourceAsStream("resource.properties");
但我这个类还要实现写入的功能,如何才能得到该文件的路径啊?
然后你看着办吧!另外,如果拿不到
URL = new URL("com/aa/bb/resource.properties");
new FileOutputStream(new File(new URL("com/aa/bb/resource.properties").toURI()));
或者:
new FileOutputStream(new File(new URL("resource.properties").toURI()));
都不行,请问如何是好?这个配置文件由于特殊原因,不能直接放到classpath下。
getClass().getResource("File");