Java tutorial
//package com.java2s; import android.content.Context; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static String readRawTextFile(Context ctx, int resId) { InputStream inputStream = ctx.getResources().openRawResource(resId); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int i; try { i = inputStream.read(); while (i != -1) { byteArrayOutputStream.write(i); i = inputStream.read(); } inputStream.close(); } catch (IOException e) { return null; } return byteArrayOutputStream.toString(); } }