Java URL Load readContentsToString(URL url)

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

Description

read Contents To String

License

Open Source License

Declaration

public static String readContentsToString(URL url) throws IOException 

Method Source Code


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

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

public class Main {
    public static String readContentsToString(URL url) throws IOException {
        LineNumberReader reader = new LineNumberReader(new InputStreamReader(url.openStream()));
        StringBuilder content = new StringBuilder();

        String line;/*from  www . java2 s. c om*/
        while ((line = reader.readLine()) != null)
            content.append(line);

        return content.toString();
    }
}

Related

  1. readContent(URL url)
  2. readContentFromFile(URL u, String encoding)
  3. readContents(URL url)
  4. readContentsToArray(URL url)
  5. readContentsToList(URL url)
  6. readData(String url)
  7. readFile(URL file)
  8. readFile(URL url)
  9. readFile(URL url)