---
title: "Java读取属性配置文件时直接处理中文 "
author: "bigguo"
date: "2016-05-09T17:32:29Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2016-05-09T17:32:29Z"
id: 2296903
url: "https://bigguo.iteye.com/blog/2296903"
---

一般介绍的方法都是把属性文件这个的中文，先用native2ascii.exe将其转换成\\uXXXX\\uXXXX这样的形式。

其实可以使用读取流指定编码格式的方式：

```
Properties prop = new Properties();
prop.load(new InputStreamReader(Config.class.getResourceAsStream("config.properties"), "UTF-8")); // Config是本语句所在的类
```