Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileOutputStream;

import java.io.OutputStream;

import android.graphics.Bitmap;

import android.os.Environment;
import android.util.Log;

public class Main {
    public static void saveBitmap(Bitmap bitmap, String fileName) {
        long time = System.currentTimeMillis();
        String filePath = Environment.getExternalStorageDirectory() + "/" + fileName;
        try {
            OutputStream stream = new FileOutputStream(filePath);
            bitmap.compress(Bitmap.CompressFormat.PNG, 80, stream);
            stream.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        Log.d("artbook", "save bitmap time: " + (System.currentTimeMillis() - time));
    }
}