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
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply 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
Ranch Hand

Joined: Jan 08, 2009
Posts: 1188

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
Ranch Hand

Joined: Jan 08, 2009
Posts: 1188

May be you can switch to StringBuffer instead of StringBuilder and see if it helps.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Not able to convert large sized byte array to String
 
Similar Threads
Uploading a text file to a blob in MySql, then downloading that file to local file system
JSP Page For Uploading a File to Destination Folder
My FileUploadServlet not uploading a file if its size exceeds 1KB
request cannot be resolved. any imports missing??
Type conversion between Bytes and Strings