ITeye博客

Myeclipse 读取中文路径的配置文件

还有也许 · 2012-09-20 17:25 · java · 编程语言 · Myeclipse · Markdown

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; 
}

 

重要的就是这一句,进行一下编码方式的转换,即可。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。