Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to convert large sized byte array to String

 
Kinnaree Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have written a code to upload file to server. When the files are small (around 3MB), it works great. But when i try to upload files of greater size, around 5MB, I start getting OutOfMemory errors (on local machine) and the file does not get upload when I upload EAR to UAT environment. On UAT environment, I do not get any significant errors in log and a open dialog pop up appears while file is being uploaded, ultimately doing nothing. Below is my code that seems to create problems:



On local, when I debug to line System.out.println("saveFile : " + saveFile); it gives me out of memory error. The problem is that dataBytes is not getting converted to file at file = new String(dataBytes);

Any suggestions would be a great help at this stage. I am working on tight deadline and unfortunately none of the solutions found through googling worked!

Thanks,
Kinnaree
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this help?
 
Kinnaree Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swastik,

Not really. We are still using jdk1.4
 
Swastik Dey
Rancher
Posts: 1609
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you can switch to StringBuffer instead of StringBuilder and see if it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic