由于在使用ORACLE和iReport,但是iReport里面不支持CLOB,我又写了个类,把CLOB字段指定为InputStream,然后通过转换变成String。
英文是可以的,但是中文就不行了,以下是部分代码:public String inputStream2String (InputStream in) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
} return out.toString();
}怎么做下编码格式的转换?分不多,但是很急,希望大家能帮忙。
英文是可以的,但是中文就不行了,以下是部分代码:public String inputStream2String (InputStream in) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
} return out.toString();
}怎么做下编码格式的转换?分不多,但是很急,希望大家能帮忙。
解决方案 »
- web服务器 处理用户请求的进程
- 请问递归在实际工作中有用吗?
- 看看这段代码,关于Http的问题,很不解
- 求:将Oracle的SQL语句 转换成 SqlServer 的SQL语句的方法
- 在一个JSP页面里写程序,动态读取数据库里的内容,在最后的JavaScript问题上卡住了,我想让所有的radio都被选择上,都可以成功提交到下一个页面,请大家帮忙!!!
- 怎样判断一个字符占用两个字节
- 请教
- the type xxx can not be resolved .it is indirectly referenced from required .class files
- 在JAVA中如何能够获得指定的文件大小? ( 有例子的给帖一个,谢了)
- --------请大家进来谈谈您所从事的有关java的工作,以及以后的打算--------
- 一个泛型方法不是很理解
- JWindow的setLocationByPlatform(),setAlwaysOntop()
String s = in.toString();
oracle.sql.CLOB clob = (oracle.sql.CLOB)in;
String ClobString = "";
try{
Reader ClobReader;
StringBuffer ClobResult = new StringBuffer();
ClobReader = clob.getCharacterStream();
BufferedReader ClobBR = new BufferedReader(ClobReader);
String ClobStr = ClobBR.readLine();
while(ClobStr != null){
ClobResult.append(ClobStr);
ClobStr = ClobBR.readLine();
}
ClobString = ClobResult.toString();
}catch(Exception e){
e.printStackTrace();
}
return ClobString;
}使用了这个Scriptlet,把CLOB字段的设为Object,然后就好了。