Myeclipse 读取中文路径的配置文件
public String getValue(String key) throws Exception{ Properties properties = new Properties(); //文件被放在classes的根路径下,如果不在自己改 InputStream in =PropertyUtil.class.getClassLoader ().getResourceAsStream("demo.properties"); properties.load(in); String value =new String (properties.getProperty(key).getBytes("ISO-8859-1"),"GBK");return value; }
?
重要的就是这一句,进行一下编码方式的转换,即可。