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
Developer
Posts: 139
Registered: ‎10-24-2010
My Device: BlackBerry 10 Dev Alpha

Re: base64Binary decoding

thanks,

 

plz go on this thead and give me answer

 

http://supportforums.blackberry.com/t5/Java-Development/How-send-2Mb-xml-file-on-server/td-p/697705

 

how we can make chunks. 

 

This question is not related to this post so that's why refring other thread.

--
please mark posts as solved if you found a solution.
press the like button on the right side to thank the user that helped you.
------------------------------------------------------------
Riz
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: base64Binary decoding

@paulkayuk

 

Apologies, I don't like the code because it does seem to introduce the possibility of a byte to String conversion, but the way you have coded it, this does not happen.

 

However I suspect the following is more efficient and uses less memory, since it converts from byte to byte (avoiding the byte to char, then to String, then to byte).

 

byte[] b = YourBase64EncodedString.getBytes();

byte[] _raw = decodeBase64(b, 0, b.length);

Bitmap _image = Bitmap.createBitmapFromBytes( _raw, 0, -1, 1 );

 

// Decodes the given byte array from Base64.

// Offset and length specify which part of the array to decode.

// The decoded data is returned as a byte array.

public static byte [] decodeBase64( byte[] toDecode, int offset, int length )

{

    // Create the input byte array to pass in the content.

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( toDecode, offset, length );

    // Create the base64 input stream.

    Base64InputStream base64InputStream = new Base64InputStream(byteArrayInputStream);

    byte [] returnBytes = IOUtilities.streamToBytes(base64InputStream);
    return returnBytes;
}

Developer
Posts: 133
Registered: ‎04-30-2010
My Device: Curve 8520

Re: base64Binary decoding

@Peter_Strange Cheers Peter, that IS much more efficient
Contributor
Posts: 12
Registered: ‎01-21-2013
My Device: BB10

Re: base64Binary decoding

can i find a boot code from converting image in bb10 !!!

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: base64Binary decoding

I think you are in the wrong forum. 

 

Have a look at the possibilitities here:

http://supportforums.blackberry.com/t5/Application-Platforms/ct-p/app_plat

 

and choose a BB10 related forum for the question. 

 

OK?