Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;

import android.os.Environment;
import android.util.Base64;

public class Main {
    public static String setImBin(String fName) {
        FileInputStream fileInputStream = null;

        File file = new File(Environment.getExternalStorageDirectory().getPath(), "Pictures/" + fName);

        byte[] bFile = new byte[(int) file.length()];

        try {
            fileInputStream = new FileInputStream(file);
            fileInputStream.read(bFile);
            fileInputStream.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return Base64.encodeToString(bFile, Base64.DEFAULT);
    }
}