---
title: "Eclipse中输入汉语, 读取出来乱码"
author: "liangxianfu5811"
date: "2014-03-20T10:42:49Z"
tags: []
categories: ["编程语言"]
slug: "eclipse"
draft: false
lastmod: "2014-03-20T11:35:13Z"
id: 2033908
url: "https://love5811.iteye.com/blog/2033908"
---

InputStreamReader reader = new InputStreamReader(System.in,"UTF-8");
String name = new BufferedReader(reader).readLine();

Scanner scanner = new Scanner(System.in, "UTF-8");
String id = scanner.nextLine();

我在console中输入中文后，每次读出来都乱码,
网上查了下说设置workplace的编码和run configuration中common的编码
我都试过了(都已经改为 utf-8)。 
用system.out.println(System.getProperty("file.encoding"));打印出来的结果也是 utf-8。
注：我一般将整个Eclipse环境设置成UTF-8编码格式。

--------------------解决方案--------------------
1)、关闭Eclipse。

2)、eclipse.exe同目录下eclipse.ini加一句:
	-Dfile.encoding=utf-8 
	保存 eclipse.ini

3)、再打开Eclipse