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 java.io.*;

public class Main {
    public static void saveFile(Bitmap bm, String path, String fileName) throws IOException {
        String uri = path;
        if (!uri.endsWith("/")) {
            uri = uri + "/";
        }
        uri = uri + fileName;
        File dirFile = new File(path);
        if (!dirFile.exists()) {
            dirFile.mkdir();
        }
        File myCaptureFile = new File(uri);
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
        bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
        bos.flush();
        bos.close();
        // SharedPreferences sp=
    }
}