package lan.my.zooty.andyscan;

import java.lang.Runnable;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.Exception;
import android.util.Log;

public class PictureSaver implements Runnable {

   File jpegFile;
   byte[] jpegData;
   String Tag="Saver";

   PictureSaver(String fileName, byte[] data) {
      Log.i(Tag,"In PictureSaver constructor");
      this.jpegFile = new File(fileName);
      jpegData = data;
   }

   public void run() {
      Log.i(Tag, "Saving " + jpegFile);
      try {
         FileOutputStream fos = new FileOutputStream(jpegFile);
         fos.write(jpegData, 0, jpegData.length);
         fos.close();
      } catch (Exception ex) {
         Log.e(Tag, "Saving jpeg failed", ex);
      }
      jpegData = null;
   }
}
