---
title: "Myeclipse 读取中文路径的配置文件"
author: "还有也许"
date: "2012-09-20T17:25:14Z"
tags: ["Myeclipse"]
categories: ["编程语言"]
slug: "myeclipse"
draft: false
lastmod: "2012-09-20T17:25:14Z"
id: 1682497
url: "https://yanzhenwei.iteye.com/blog/1682497"
---

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

 

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