The code uses non standard classes found in the sun.misc package to convert to and from Base64. These classes may change in the future. Taken from Example Depot.

Say you call an HTTP request that returns a byte array which contains a binary file, how would you do this? First things first. Access it using an HttpURLConnection object. Once you have connected to the URL, get the InputStream object and that is when you will be able to convert the stream into a byte array. Check the code below.

The data variable is the byte array. You can then do whatever you like (e.g. saving it as a binary file) after you have retrieved the byte array object.

Related Posts Plugin for WordPress, Blogger...