Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;

import android.os.Environment;

public class Main {

    public static void saveMyBitmap(String bitName, Bitmap mBitmap) throws IOException {
        String myJpgPath = Environment.getExternalStorageDirectory() + "/pepper/" + "1.png";
        File tmp = new File("/sdcard/pepper/");
        if (!tmp.exists()) {
            tmp.mkdir();
        }
        File f = new File(myJpgPath);
        f.createNewFile();
        FileOutputStream fOut = null;
        try {
            fOut = new FileOutputStream(f);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
        try {
            fOut.flush();
            fOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}