Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.net.Uri; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readTextFromUri(Context context, Uri uri) throws IOException { InputStream inputStream = context.getContentResolver().openInputStream(uri); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { stringBuilder.append(line); } inputStream.close(); reader.close(); return stringBuilder.toString(); } }