Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 38
Registered: ‎03-13-2012
My Device: 9860
My Carrier: 1234

Base64InputStream.decode throwing decode Error

Ive tried alsorts now.

 

Base64InputStream.decode Doesnt work if the array is greater than 64k... throwing decode Error.

 

So following others advice in looping a read, I randomly get decode Error.

 

Its very important that it works 100%.. 

 

            ByteArrayInputStream bis = new ByteArrayInputStream(input, 0, input.length);
            Base64InputStream b64 = new Base64InputStream(bis);
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] buff = new byte[1024]; // faster than byte-at-a-time
            for (int len = b64.read(buff); len != -1; len = b64.read(buff)) {
                bos.write(buff, 0, len);
            }
            byte[] decoded = bos.toByteArray();