解决saiku读取配置文件乱码
来源:互联网 发布:python 转换为字典 编辑:程序博客网 时间:2024/05/25 21:35
最近使用到 saiku自助查询工具
但是中文乱码问题在saiku中是一个很难处理的问题
下面介绍一下我如何处理读取配置文件乱码问题的
拿saiku给的示例来说
首先要保证 sales.txt文件的编码格式是 utf-8的(这个是不是必须的,暂时不清楚),
其次修改 ClassPathRespurceDataResourceManager类中的load方法
原始方法是这样的:
public void load() {datasources.clear();try {if (repoURL != null) {File[] files = new File(repoURL.getFile()).listFiles();for (File file : files) {if (!file.isHidden()) {Properties props = new Properties();props.load(new FileInputStream(file));String name = props.getProperty("name");String type = props.getProperty("type");if (name != null && type != null) {Type t = SaikuDatasource.Type.valueOf(type.toUpperCase());SaikuDatasource ds = new SaikuDatasource(name, t, props);datasources.put(name, ds);}}}} else {throw new Exception("repo URL is null");}} catch (Exception e) {throw new SaikuServiceException(e.getMessage(), e);}}
修改后的方法是这样的
public void load() {datasources.clear();try {if (repoURL != null) {File[] files = new File(repoURL.getFile()).listFiles();for (File file : files) {if (!file.isHidden()) {Properties props = new Properties();FileInputStream in = new FileInputStream(file);props.load(new InputStreamReader(in, "UTF-8"));String name = props.getProperty("name");String type = props.getProperty("type");if (name != null && type != null) {Type t = SaikuDatasource.Type.valueOf(type.toUpperCase());SaikuDatasource ds = new SaikuDatasource(name, t, props);datasources.put(name, ds);}}}} else {throw new Exception("repo URL is null");}} catch (Exception e) {throw new SaikuServiceException(e.getMessage(), e);}}从上面两段代码中可以看出,在读取配置文件的时候是在读取的时候设置为 utf-8的编码,这样在前段展示的时候中文乱码就没有了
0 0
- 解决saiku读取配置文件乱码
- 解决生成的saiku文件读取中文乱码的问题
- jsp读取配置文件乱码解决
- java读取properties配置文件,并解决中文乱码
- Springboot解决IDEA读取properties配置文件的中文乱码
- 读取配置文件乱码
- SpringBoot读取配置文件乱码
- PropertyUtil 读取 乱码解决
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 关于Spring boot中读取属性配置文件出现中文乱码的问题的解决
- Springboot 之 解决IntelliJ IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 修改tomcat 配置文件解决乱码
- 解决php读取数据库乱码
- 第一个u3d程序,hello world(UGUI)
- XML文档类型定义---XML Schema结构
- 浅谈Android内存优化
- iOS二维码扫描
- Syntax error on tokens, delete these tokens
- 解决saiku读取配置文件乱码
- 高斯模糊算法的 C++ 实现
- 日常小结-配置https连接器
- Datamill 一个开源的框架
- Bugtags接入
- 计算分数的精确值-高精度除法
- 项目从eclipse迁移到as
- 268. Missing Number
- 阿拉伯数字转换为汉字数字