Description
Convert a Clob into String.
License
Open Source License
Parameter
Parameter | Description |
---|
clob | a parameter |
Exception
Parameter | Description |
---|
SQLException | an exception |
IOException | an exception |
Declaration
public static String convertClob2String(Clob clob) throws SQLException, IOException
Method Source Code
//package com.java2s;
/**/*from ww w .j a v a 2 s. c om*/
* $Header: /home/master/nWave-DM-Common/src/com/npower/dm/util/DMUtil.java,v 1.6 2007/08/29 06:21:00 zhao Exp $
* $Revision: 1.6 $
* $Date: 2007/08/29 06:21:00 $
*
* ===============================================================================================
* License, Version 1.1
*
* Copyright (c) 1994-2006 NPower Network Software Ltd. All rights reserved.
*
* This SOURCE CODE FILE, which has been provided by NPower as part
* of a NPower product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of NPower.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD NPower, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
* ===============================================================================================
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.sql.Clob;
import java.sql.SQLException;
public class Main {
/**
* Convert a Clob into String.
*
* @param clob
* @return
* @throws SQLException
* @throws IOException
*/
public static String convertClob2String(Clob clob) throws SQLException, IOException {
if (clob != null) {
BufferedReader in = new BufferedReader(clob.getCharacterStream());
String line = in.readLine();
StringBuffer result = new StringBuffer();
while (line != null) {
result.append(line);
line = in.readLine();
}
// Could not close the Reader, which will cause
// a SQLException(Could not reset the Reader) when next time to call this
// method.
// in.close();
return result.toString();
}
return null;
}
}
Related
- convert(Object o, Class> targetType)
- ConvertClobToString(StringBuffer sb, Clob clob)
- convertToString(Object obj)
- getClobToString(Clob clob)
- getFormattedClobColumn(final InputStream is)