将Clob对象转换成String对象

2015-11-21 01:04:38 · 作者: · 浏览: 8
/**
	 * 将Clob对象转换成String对象
	 * @param clob
	 * @return
	 * @throws SQLException
	 * @throws IOException
	 */
	public static String ClobToString(Clob clob) throws SQLException, IOException{
		String str="";
		Reader reader=clob.getCharacterStream();//得到流
		BufferedReader bReader=new BufferedReader(reader);
		String s = bReader.readLine();
		StringBuffer strBuffer = new StringBuffer();
		while(s!=null){//执行循环将字符串全部取出附值给StringBuffer由StringBuffer转成String
			strBuffer.append(s);
			s=bReader.readLine();
		}
		str=strBuffer.toString();
		return str;
	}