修改内容为如下(重点是红色内容):
InputStream in = readVirtualFile(catalogUrl);
try {
return IOUtils.toString(in,"utf-8"); //-----------------此行为红色行
} finally {
IOUtils.closeQuietly(in);
}
或者按照网上说的另外一种方式,整体替换为如下内容,也可以,不过下面的编码必须写你的schema文件的编码:
try {
final byte[] bytes = Util. readFully(in, 1024);
final char[] chars = new char[bytes. length];
for ( int i = 0; i < chars. length; i++) {
chars[i] = ( char) bytes[i];
}
String str = new String(bytes,"utf-8").replace("\ufeff" , "" );//加replace("\ufeff", "")是为了过滤"UTF-8无BOM格式文件"的开头
return str;
} finally {
if (in != null) {
in.close();
}
}2、再找到文件 mondrian.rolap.RolapSchema.lo
1、根据文档中,比较费解,没有看太懂(并且部分文档的方法无法使用):http://mondrian.pentaho.com/documentation/cache_control.php
2、本来打算使用文档中的另一个方法
但是最终发现我完全从外部调用,哪里获取RolapConnection呢,于是,此方法宣告失败
public boolean clearCache() throws Exception {
if ( olapConnection.isWrapperFor( RolapConnection.class ) ) {
System.out.println( "Clearing cache" );
RolapConnection rcon = olapConnection.unwrap( RolapConnection.class );
rcon.getCacheControl( null ).flushSchemaCache();
}
return true;
}
3、经过努力,找到别人的方法,此方法可行,原文是
java.util.Iterator<mondrian.rolap.RolapSchema> schemaIterator = mondrian.rolap.RolapSchema.getRolapSchemas();
while(schemaIterator.hasNext()){
mondrian.rolap.RolapSchema schema = schemaIterator.next();
mondrian.olap.CacheControl cacheControl = schema.getInternalConnection().getCacheControl(null);
for (mondrian.olap.Cube cube : schema.getCubes()) {
cacheControl.flush(cacheControl.createMeasuresRegion(cube));
}
}但是对于我用的版本不对应,会报无法转换为Iterator,然后做了稍微修改,如下
List<mondrian.rola