Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;

import java.util.Properties;

import android.content.Context;

public class Main {
    private static final String FILE_ENCODING = "utf-8";

    /**
     * (android) read from file
     * 
     * @param fileName
     * @return
     */
    public static String androidFileload(Context con, String fileName) {
        Properties properties = new Properties();
        try {
            FileInputStream stream = con.openFileInput(fileName);
            properties.load(stream);
        } catch (FileNotFoundException e) {
            return null;
        } catch (IOException e) {
            return null;
        }

        return properties.get(FILE_ENCODING).toString();
    }
}