Bookmark Topic Watch Topic
  • New Topic

java.lang.outOfMemory

 
Monty Guppy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I am trying to read from an inputSource and stored the read characters into a stringbuffer. This is causing the outOfMemory beyond certain sized datasource (data that I am returning in the form of XML from Oracle). I read somewhere that I can buffer the read and thus overcome this problem. However, I am not sure how to implement it codewise.
Here is my code (works great for files upto 0.5MB):
int c;
InputStream in=clobXML.getAsciiStream();
while ((c = in.read()) != -1) {sb.append((char) c);}
Can someone please help me as to how to modify this code? Thanks
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Report post to moderator
Not sure if this will help, but are you talking about using a BufferedInputStream? If so, construct it like so:
BufferedInputStream buffer = new BufferedInputStream( clobXML.getAsciiStream() );
Then you can read like normal.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!