Thread:
 Temporary Clob solution - nullSafeGet method eats ... 
 ericmason   14 Jan 2004, 06:34 
 Re: Temporary Clob solution - nullSafeGet metho... 
 rgodfrey   15 Jan 2004, 16:55 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: ericmason (14 Jan 2004, 06:34) Replies: 1, Views: 38924
Subject: Temporary Clob solution - nullSafeGet method eats newli...
If you're going to throw that class into your project and use it
verbatim, you might want to change nullSafeGet as follows:
<snip>
	String lineSeparator = System.getProperty("line.separator");
	StringBuffer sb = new StringBuffer();
    BufferedReader bufferedClobReader = new BufferedReader(clobReader);
    try
    {
      String line = null;
      while( (line = bufferedClobReader.readLine()) != null )
      {
      	sb.append(line + lineSeparator);
      }
      bufferedClobReader.close();
    }
    catch (IOException e)
    {
      throw new SQLException( e.toString() );
    }

    return sb.toString();
<snip>

Changes: 
1. Adds the line separator back in, as the BufferedReader removes it.  
2. Uses a string buffer, which I'm told is faster than instantiating
tons of strings.

There may be a better way to do this, but I tested this one and I know
it works.  :)
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]