Android URL Read readFile(URL url)

Here you can find the source of readFile(URL url)

Description

read File

License

Open Source License

Declaration

public static String readFile(URL url) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class Main {
    public static String readFile(URL url) {
        String result = "";

        try {/*from  w ww.  ja v a2 s.co m*/
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    url.openStream()));
            String inputLine = "";
            while (inputLine != null) {
                result += inputLine + "\n";
                inputLine = in.readLine();
            }
            in.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return result;
    }
}

Related

  1. getResource(String filename)
  2. getXML(String url)
  3. readXmlFromUrl(String address)
  4. getStringFromUrl(String url)
  5. getFileDateTime(URL url)