Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

java.lang.outOfMemory

 
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
 
Chicken Farmer ()
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.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic