關於讀取properties檔案中文亂碼問題

2021-10-05 20:53:12 字數 471 閱讀 6193

//讀取配置檔案資訊

inputstream config = thread.

currentthread()

.getcontextclassloader()

.getresourceasstream

("config.properties");

//使用property集合載入流資料

properties properties =

newproperties()

;//使用 properties.load(config)出現中文亂碼,使用轉換流,將位元組流轉換成字元流,同時指定轉換檔案編碼方式

properties.

load

(new

inputstreamreader

(config,

"utf-8"))

;//亂碼解決..

.

mybatis讀取properties檔案內容

今天在mybatis中想讀取檔案內容,一開始是建立的xml檔案,發現必須要表頭,不然就是 完全不適用,然後突然靈光一現,可以建立properties檔案,讀取檔案,通過鍵值對獲取內容。properties proper new properties proper.load this.getclass...

java sdk讀取properties檔案

獲得properties檔案中key為classname的值 resourcebundle bundle resourcebundle.getbundle data 通過getbundle獲得src下properties檔案 檔名為data.properties 獲得值 string classna...

properties 檔案讀取

假設在src根目錄下有檔案 config.properties 下面 就是讀取這個檔案的例子程式 方法1 properties prop new properties inputstream in object.class.getresourceasstream config.properties ...