Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    private static final String TAG = "BitmapUtils";

    /**
     * Writes an image to file
     *
     * @param src  the image to write
     * @param file the destination file
     * @return true in case of success, false otherwise
     */
    private static boolean writeBitmapToFile(Bitmap src, File file) {
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(file);
            src.compress(Bitmap.CompressFormat.JPEG, 70, out); // bmp is your Bitmap instance
            return true;
        } catch (Exception e) {
            Log.d(TAG, "Error writing image", e);
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                Log.d(TAG, "Error writing image", e);
            }
        }
        return false;
    }
}