---
title: "oracle.sql.CLOB 转 String"
author: "cevin15"
date: "2012-04-27T18:24:34Z"
tags: []
categories: ["编程语言"]
slug: "oracle-sql-clob-string"
draft: false
lastmod: "2012-04-27T18:24:56Z"
id: 1502553
url: "https://cevin15.iteye.com/blog/1502553"
---

最近在用oracle数据库，有个oracle.sql.CLOB转String的需求。
方法如下，也给自己备忘。

```java
	public String clobToString(CLOB clob) {
		String reString = null;
		try {
			Reader is = clob.getCharacterStream();
			BufferedReader br = new BufferedReader(is);
			String s = br.readLine();
			StringBuffer sb = new StringBuffer();
			while (s != null) {
				sb.append(s);
				s = br.readLine();
			}
			reString = sb.toString();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return reString;
	}
```