Strange behaviour.....file size changes
<p>I have written an android program to copy an image from a location in the SD card and make a copy of it.To my surprise the size of the image changes.Any one who can help me on this issue please do the same....
Thanking you in advance..    </p>

<p>package make.image.bw;</p>

<pre><code>import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.ImageView;

public class MakeImageBWActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);                  // set screen view
        String imageInSD      =     Environment.getExternalStorageDirectory().getAbsolutePath() +"/earth.jpg";
        RandomAccessFile file =     null;
        long count=0;
        try {
            file = new RandomAccessFile(imageInSD, "r");
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        File myFile               =     new File(Environment.getExternalStorageDirectory(), "myearth.jpg");

        byte[] buffer             =     new byte[1024];
        try {
            FileOutputStream out  =     new FileOutputStream(myFile);
            while(file.read(buffer)!=-1){
                   out.write(buffer,0,1024);
                   count++;
            }
              out.flush();
              out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d("tag", "finished");
        finish();
        }

}
</code></pre>
