Loading
Clob To String Convertor

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  Clob To String Convertor


Ans)

ClobToStringConvertor:

This class covert the CLOB into String.

import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;

class ClobToStringConvertor {
   public static String convertClobToString(Object clobToBeConverted,
     int characterToRead) throws ICCException {
        Clob clob = (Clob) clobToBeConverted;
        String val = null;
        if (clob != null) {
            Reader reader = null;
            try {
                reader = clob.getCharacterStream();
                char chars[] = new char[characterToRead];
                StringBuffer buf = new StringBuffer();
                int count = 0;
                do {
                    count = reader.read(chars);
                    if (count > 0) {
                        buf.append(chars, 0, count);
                    }
                } while (count != -1);
                val = buf.toString();
            } catch (SQLException e) {
                logger.error(e.getMessage());
            } catch (IOException e) {
                logger.error(e.getMessage());
            }
        }
        return val;
    }
}



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Clob To String Convertor


Clob To String Convertor

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free