當Properties的key value對中含有中文時會產生亂碼 產生亂碼的代碼app
Properties properties = new Properties(); InputStream inputStream = this.getClass().getResourceAsStream("/application.properties"); properties.load(inputStream ); properties .getProperty("Full")//獲得的是亂碼 ``` 由於InputStream 不能讀取中文,因此採起reader把inputStream轉換成reader用字符流來讀取中文。 ``` Properties properties = new Properties(); InputStream inputStream = this.getClass().getResourceAsStream("/application.properties"); BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream)); properties.load(bf); properties .getProperty("Full")//亂碼問題解決了 ```