java在eclipse控制檯讀取並輸出含有中文字符的文件

將含有中文字符的txt讀取出來,並在eclipse裏顯示出來,eclipse裏也有run config的common裏有配置輸出字符流編碼設置。 java

輸入流編碼設置爲GBK就OK了 eclipse

//read the chinese string.
	public void readFile() throws Exception{
		BufferedReader  reader=new BufferedReader(new InputStreamReader(new FileInputStream("F:\\estateTable.txt"),"GBK"));
		String strLine=null;
	    if ((strLine = reader.readLine()) != null){
	    	System.out.println(strLine);
	    }
	    reader.close();
	}
相關文章
相關標籤/搜索