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 android.graphics.Bitmap;

import android.os.Environment;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

public class Main {
    public static File savebitmap(Bitmap bitmap) {
        OutputStream outStream = null;
        File folder = new File(Environment.getExternalStorageDirectory().toString() + "/InSyte");
        folder.mkdirs();
        String mDirectory = folder.toString();
        File file = new File(mDirectory, "IMG_" + System.currentTimeMillis() + ".jpg");
        try {
            outStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
            outStream.flush();
            outStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return file;

    }
}