Android读取xxx.properties配置文件中文出现乱码解决方法
2016-12-21 10:31
1131 查看
android读取assets中的配置文件英文没问题,但是中文会出现乱码的问题,前提配置文件已经是utf-8的格式了
出现问题的代码:
经过修改后就没有以上的问题了,不要让properties直接去load流文件就可以了
出现问题的代码:
@Override public void start() { try { Properties properties = new Properties(); InputStream inputStream = context.getAssets().open("config.properties");、 properties.load(inputStream); myPackage = properties.getProperty("mypackage"); myName = properties.getProperty("myname"); myGitHub = properties.getProperty("mygithub"); myCSDN = properties.getProperty("mycsdn"); } catch (IOException e) { e.printStackTrace(); } }
经过修改后就没有以上的问题了,不要让properties直接去load流文件就可以了
@Override public void start() { try { Properties properties = new Properties(); InputStream inputStream = context.getAssets().open("config.properties"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); properties.load(bufferedReader); myPackage = properties.getProperty("mypackage"); myName = properties.getProperty("myname"); myGitHub = properties.getProperty("mygithub"); myCSDN = properties.getProperty("mycsdn"); } catch (IOException e) { e.printStackTrace(); } }
相关文章推荐
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- java读取*.properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Spring读取properties文件出现乱码的解决方法
- C#读取中文文件出现乱码的解决方法
- ResourceBundle (读取properties文件及中文乱码解决方法)
- ResourceBundle (读取properties文件及中文乱码解决方法)
- Android读取中文文件乱码解决方法
- Eclipse中properties文件读取时中文乱码、指定更新、写入中文变unicode码的解决方法
- properties配置文件中文乱码解决方法
- 关于Spring boot中读取属性配置文件出现中文乱码的问题的解决
- Spring读取properties文件出现乱码的解决方法
- Spring读取properties文件出现乱码的解决方法
- java获得*.properties配置文件的值,解决读取中文时乱码的问题:
- iOS读取txt文件出现中文乱码的解决方法
- spring使用@Value注解读取.properties文件时出现中文乱码问题的解决