While converting byte[] array to String got exception in android
<pre><code>float rotation =getRotatedImage(imgdata);
</code></pre>

<p>//Where imgdata is the String which is require on method getRotatedImage(imgdata).</p>

<p>//My own method to get the oreintation of picture</p>

<pre><code>private float getRotatedImage(String imgdata2) {
         try {
            ExifInterface exif = new ExifInterface(imgdata2);
            int rotation = (int)exifOrientationToDegrees(
                    exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                            ExifInterface.ORIENTATION_NORMAL));
            return rotation;
        } catch (IOException e) {
            Log.e("CAMERA IMAGE", "Error checking exif", e);
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // TODO Auto-generated method stub
        return 0f;
    }
</code></pre>

<p>// inside on picture taken i am converting the byte data to String</p>

<pre><code>@Override
    public void onPictureTaken(byte[] arg0, Camera arg1) {
        Log.i("CAMERA", "ON PICTURE TAKEN");
        int length = arg0.length;
        if (length != 0) {

            //bitimage = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);

            finalimage = arg0;
            if(finalimage!=null)
            {
                imgdata=converttostring(finalimage);
            }
            //compressimageforshow();
            Toast.makeText(getApplicationContext(), "IMAGE PROCESSING DONE", 0)
                    .show();

        } else {
            Toast.makeText(getApplicationContext(), "NO IMAGE ", 0).show();
        }
        arg1.startPreview();
        //shutterButton.setEnabled(false);
        show_image_bt.setEnabled(true);

    }
</code></pre>

<p>//Here my method in order to convert to string</p>

<pre><code>private String converttostring(byte[] finalimage2) {
        // String basestr=Base64.encodeToString(finalimage2, Base64.NO_WRAP);

        return new String(finalimage2);

    }
</code></pre>

<p>//Here is my logcat exception details:</p>

<pre><code>01-22 18:06:48.808: I/ACTIVITY(344): ON CREATE
01-22 18:06:48.808: I/ACTIVITY(344): ON RESUME
01-22 18:06:49.348: I/CAMERA(344): ON SURFACE CHANGE
01-22 18:06:53.018: I/CAMERA(344): ON PICTURE TAKEN
01-22 18:06:56.188: E/(344): can't open '������JFIF����`��`��������fExif����II*������������������&gt;��������������F������(��������������1��������N��������������`������������`������������Paint.NET v3.36������C��
01-22 18:06:56.188: E/(344): 
01-22 18:06:56.188: E/(344): 
01-22 18:06:56.188: E/(344): 

����C       

�������@"�������������������������� 
01-22 18:06:56.188: E/(344): �����������}��!1AQa"q2���#B��R��$3br�  
01-22 18:06:56.188: E/(344): %&amp;'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������������������   
01-22 18:06:56.188: E/(344): ���������w��!1AQaq"2�B���� #3R�br�
01-22 18:06:56.188: E/(344): $4�%�&amp;'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�����������������
</code></pre>

<p>//so please can anyone tell me what to do also tried the Base64 of android class</p>

<pre><code>imgdata=Base64.encodeToString(finalimage,Base64.NO_WRAP);
</code></pre>

<p>where imgdata is string ,finalimage is the byte array.</p>

<p>Waiting for reply.Please forgive me for my language and coding style.</p>

<p>//Here i am mentioning the button click event for which the exception is generating</p>

<pre><code>@Override
    public void onClick(View arg0) {
        switch (arg0.getId()) {
case R.id.show_image:
            show_image_imgvw.setVisibility(View.VISIBLE);
            retake_photo_bt.setEnabled(true);
            show_image_bt.setEnabled(false);
            preview.setVisibility(View.INVISIBLE);

            if (finalimage != null) {
                resizeimageforshow();
                show_image_imgvw.setImageBitmap(bitimage);
                Toast.makeText(getApplicationContext(), "IMAGE DISPLAYED", 0)
                        .show();
</code></pre>

<p>on click of this button exception is generating.
// inside the resizeimagefroshow() calling  the getRotatedimage() and after that creating new bitmap 
image for display</p>

<p>//code here:</p>

<pre><code>private void resizeimageforshow() {
        if (finalimage != null) {
            // bitimage=BitmapFactory.decodeByteArray(finalimage, 0,
            // finalimage.length);
            // show_image_imgvw.setImageBitmap(bitimage);
            Bitmap myimage1 = BitmapFactory.decodeByteArray(finalimage, 0,
                    finalimage.length);
            // imgdata=Base64.encodeToString(finalimage,Base64.NO_WRAP);
            android.graphics.Matrix matrix = new android.graphics.Matrix();
            float rotation = getRotatedImage(imgdata);
            if (rotation != 0f) {
                matrix.preRotate(rotation);
            }
            bitimage = Bitmap.createBitmap(myimage1, 0, 0, myimage1.getWidth(),
                    myimage1.getHeight(), matrix, true);
</code></pre>
