Java URL Load readFileIntoString(URL url)

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

Description

read File Into String

License

Open Source License

Declaration

public static String readFileIntoString(URL url) throws IOException 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String readFileIntoString(URL url) throws IOException {
        final char[] buffer = new char[0x10000];
        StringBuilder str = new StringBuilder();
        Reader in = new InputStreamReader(url.openStream(), "UTF-8");

        int read;
        do {/*from  w ww.ja v a 2 s  .c o m*/
            read = in.read(buffer, 0, buffer.length);
            if (read > 0) {
                str.append(buffer, 0, read);
            }
        } while (read >= 0);

        return str.toString();
    }
}

Related

  1. readFile(URL url)
  2. readFileContent(URL file)
  3. readFileFromURL(URL url)
  4. readFileIntoMap(URL url)
  5. readFileIntoString(URL input)
  6. readFromFile(URL fileName)
  7. readFromFile(URL source)
  8. readFromUrl(String url)
  9. readFromUrl(String urlString)