Java URL Load readText(final URL url)

Here you can find the source of readText(final URL url)

Description

read Text

License

Open Source License

Declaration

public static String readText(final URL url) throws IOException 

Method Source Code

//package com.java2s;
/*//  w ww .java  2 s .  c om
 *  Copyright (C) 2011-2014 Brian Groenke
 *  All rights reserved.
 * 
 *  This file is part of the 2DX Graphics Library.
 *
 *  This Source Code Form is subject to the terms of the
 *  Mozilla Public License, v. 2.0. If a copy of the MPL 
 *  was not distributed with this file, You can obtain one at 
 *  http://mozilla.org/MPL/2.0/.
 */

import java.io.*;

import java.net.URL;

public class Main {
    public static String readText(final URL url) throws IOException {

        String text = null;
        BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
        StringBuilder sb = new StringBuilder();
        String next;
        while ((next = br.readLine()) != null) {
            sb.append(next + System.getProperty("line.separator"));
        }
        br.close();
        text = sb.toString();
        return text;
    }
}

Related

  1. readServicesFromUrl(Collection list, URL url)
  2. readSqlStatements(URL url)
  3. readStopwordsURL(URL url, boolean lowercase)
  4. readStringFromUrl(URL url)
  5. readStringFromURL(URL url)
  6. readText(final URL url)
  7. readTextFile(final URL resource)
  8. readTextFileAtUrl(final URL url)
  9. readTextFromUrl(URL url)