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 java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    public static Bitmap GetFromFile(String fileName, String path) {
        String fString = fileName.replaceAll("/", ".");
        File file = new File("/sdcard/OneBus/user/" + path + "/" + fString + ".jpg");
        if (!file.exists()) {
            return null;
        }
        try {

            FileInputStream fis = new FileInputStream(file);
            return BitmapFactory.decodeStream(fis);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}