Forums Register Login

problem in converting string to byte array.

+Pie Number of slices to send: Send
Hello everybody,

I am developing an application in that I want to upload image to the server. If image is less than 900 kb then application run fine. but when image is more than 900kb then it throws exception as java.lang.OutOfMemoryError.

my code is as follows



I have Base64 class which has method


What is wrong here?

Thanks in advance.
+Pie Number of slices to send: Send
I would say your code is not properly created for mobile devices. You are reading the whole file into a byte array, then encoding it with Base64 to get a String and then again convert the whole String back to byte array. This will use a lot of memory for a mobile device to handle. Why don't you read the file in chunks like 100bytes at a time and send it to the output stream. That way you won't use that much memory...
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 8894 times.
Similar Threads
java.net.ProtocolException: Does not support output
read and write file in parts
How to encode image in parts?
How can I recieve data from servlet on j2me application?
Reading image and convert it to Base64 format
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:00:52.