java.sql.Clob类型转java.lang.String类型

/**
	 * 
	 * 方法说明:clob转字符串
	 * created by 胡升阳  2014-7-10下午1:43:18
	 * 
	 * 返回:String
	 */
	private String clob2Str(Clob clob){
		String content = "";
		try {
			Reader is = clob.getCharacterStream();
			BufferedReader buff = new BufferedReader(is);// 得到流
			String line = buff.readLine();
			StringBuffer sb = new StringBuffer();
			while (line != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
				sb.append(line);
				line = buff.readLine();
			}
			content = sb.toString();
		} catch (Exception e) {
			log.error("java.sql.Clob类型转java.lang.String类型出错..."+e.getCause());
			e.printStackTrace();
		}
		return content;
	}

你可能感兴趣的:(java.sql.Clob类型转java.lang.String类型)