aspose file tools*
The moose likes Servlets and the fly likes Not able to convert large sized byte array to String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not able to convert large sized byte array to String" Watch "Not able to convert large sized byte array to String" New topic
Author

Not able to convert large sized byte array to String

Kinnaree Patel
Ranch Hand

Joined: Oct 30, 2007
Posts: 33
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


95% people read history, 5% create it... On The Way To 5%...
SCJP 5.0 -> 88%, SCWCD -> 86%, Next -> SCBCD and SCDJWS
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Does this help?


Swastik
Kinnaree Patel
Ranch Hand

Joined: Oct 30, 2007
Posts: 33
Hi Swastik,

Not really. We are still using jdk1.4
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

May be you can switch to StringBuffer instead of StringBuilder and see if it helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to convert large sized byte array to String