Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Artistic License 

import android.content.res.AssetManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String loadData(AssetManager am) {
        String str;
        BufferedReader in = null;
        StringBuilder buf = null;
        try {
            buf = new StringBuilder();
            InputStream json = am.open("treatment.json");
            if (json != null) {
                in = new BufferedReader(new InputStreamReader(json));
                while ((str = in.readLine()) != null) {
                    buf.append(str);
                }
            }
        } catch (Exception e) {
            return "";
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return buf.toString();
    }
}