summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/se/leap/bitmaskclient/test/FromAssets.java
blob: 6a4c1ee27722cd4f87426cc7a76a73be9bee27f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package se.leap.bitmaskclient.test;

import android.content.*;

import org.json.*;

import java.io.*;

public class FromAssets {

    Context context;

    public FromAssets(Context context) {
        this.context = context;
    }

    public String toString(String filename) throws IOException, JSONException {
        String result = "";
        InputStream is = context.getAssets().open(filename);
        byte[] bytes = new byte[is.available()];
        if (is.read(bytes) > 0) {
            result = new String(bytes);
        }
        return result;
    }
}