Android URL Read readTextFromUri(Context c, Uri uri)

Here you can find the source of readTextFromUri(Context c, Uri uri)

Description

read Text From Uri

Declaration

public static String readTextFromUri(Context c, Uri uri)
            throws IOException 

Method Source Code

//package com.java2s;
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 c, Uri uri)
            throws IOException {
        InputStream inputStream = c.getContentResolver().openInputStream(
                uri);//  w  w w.  ja v a  2s  .  c  o m
        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();
    }
}

Related

  1. readFile(URL url)
  2. getXML(String url)
  3. readXmlFromUrl(String address)
  4. getStringFromUrl(String url)
  5. getFileDateTime(URL url)
  6. getHtmlByteArray(final String url)