• Post Reply Bookmark Topic Watch Topic
  • New Topic

UTF8 Encoding While Writing in File - Out Of MemoryError  RSS feed

 
Amit Arora
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have an XML file which contains UTF8 characters. I have divided it into small chunk (XML) and have transformed that chunk using XSLT into XML and have converted it into object using XMLBeans and serialize it to file and again continue it for the next chunk. Next transformed chunk will be merged with the pervious chunk to get the output. This process continues for number of chunks. I am using STAX for merging. The problem is that for writing the chunk I was using

Writer file = null;
try {
file = new FileWriter(atempDestFileName);
}
catch (IOException exception) {
throw exception;
}
That was working fine, but the UTF-8 characters were not encoded properly. So I have used the followng:

try {
file = new OutputStreamWriter(new FileOutputStream(atempDestFileName),"UTF-8");
}
catch (IOException exception) {
throw exception;
}

It has written some chunk but after some processing the system is giving the OutOfMemoryError for writing the chunk.

Any help is appreciated.

Thanks
Amit
 
Brad Walton
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually I get the OutOfMemory error when I don't properly break out of a for loop when reading/writing. Is there any more code you can post to assist in troubleshooting?
 
Amit Arora
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brad,

Thanks a lot .
I have solved the problem. Actually I am encoding the same character again and again while merging the thing. That is giving the OutOfMemoryError. It has been fixed.

Amit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!