What you have seems fine, from what I can see.

On Mon, Oct 11, 2010 at 3:54 PM, venkata raidu <[email protected]> wrote:
> Hi Mark,
>
>  I tried the following code. Although the byte array returns me some
> valid length,
>  I am doubtful if this is returning me the correct data, because our
> server throws
>  an error when I encode the bye array into Base 64 format. Please
> check. Thanks.
>
>  try {
>        InputStream inStream =
> getApplicationContext().getContentResolver().openInputStream(uri);
>
>        int length = inStream.available();
>
>        byte [] bytes = new byte[length];
>
>        int offset = 0;
>        int numRead = 0;
>
>        while (offset < bytes.length && (numRead = inStream.read(bytes,
> offset, bytes.length-offset)) >= 0) {
>
>            offset += numRead;
>
>        }
>
>
>        Log.v(TAG, "Byte Array: " + bytes.length);
>
>        String encodedString = Base64.encodeToString(bytes, Base64.DEFAULT);
>
>        } catch (IOException e) {
>
>           e.printStackTrace();
>
>        }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to