1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| package cn.stylefeng.guns.base.db.util;
|
| import java.io.BufferedReader;
| import java.io.Reader;
| import java.sql.Clob;
|
| /**
| * oracle数据库转化工具
| *
| * @author fengshuonan
| * @Date 2019/11/19 18:14
| */
| public class ClobUtil {
|
| /**
| * Clob类型转换成String类型
| *
| * @author fengshuonan
| * @Date 2019/11/19 18:14
| */
| public static String clobToString(final Clob clob) {
|
| if (clob == null) {
| return null;
| }
|
| Reader reader = null;
| try {
| reader = clob.getCharacterStream();
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| if (reader == null) {
| return "";
| }
|
| BufferedReader br = new BufferedReader(reader);
|
|
| String str = null;
|
| // 读取第一行
| try {
| str = br.readLine();
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| StringBuilder sb = new StringBuilder();
|
| // 如果没有到达流的末尾,则继续读取下一行
| while (str != null) {
| sb.append(str);
| try {
| str = br.readLine();
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
|
| return sb.toString();
| }
|
| }
|
|