Java Utililty Methods URL Load

List of utility methods to do URL Load

Description

The list of methods to do URL Load are organized into topic(s).

Method

StringreadFileIntoString(URL input)
Reads the contents of a file into a string variable.
InputStream stream = null;
InputStreamReader reader = null;
try {
    stream = input.openStream();
    reader = new InputStreamReader(stream);
    return readStreamIntoString(reader);
} finally {
    if (reader != null)
...
StringreadFileIntoString(URL url)
read File Into String
final char[] buffer = new char[0x10000];
StringBuilder str = new StringBuilder();
Reader in = new InputStreamReader(url.openStream(), "UTF-8");
int read;
do {
    read = in.read(buffer, 0, buffer.length);
    if (read > 0) {
        str.append(buffer, 0, read);
...
StringreadFromFile(URL fileName)
read From File
try {
    final StringBuffer sb = new StringBuffer();
    final char buf[] = new char[4096];
    int numRead;
    final InputStreamReader isr = new InputStreamReader(fileName.openStream(), "utf-8");
    do {
        numRead = isr.read(buf, 0, buf.length);
        if (numRead > 0)
...
StringreadFromFile(URL source)
This method takes a URL as parameter to read the contents, and to add into a string buffer.
char[] chars = new char[4092];
InputStreamReader contentsReader = null;
StringBuffer buffer = new StringBuffer();
if (!new java.io.File(source.getFile()).exists()) {
    throw new FileNotFoundException(
            TemplateEngineMessages.getString("ProcessHelper.fileNotFound") + source.getFile()); 
} else {
    contentsReader = new InputStreamReader(source.openStream());
...
StringreadFromUrl(String url)
Reads a url and returns the content as a string.
InputStream is = new URL(url).openStream();
StringBuilder sb = null;
try {
    BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    String line;
    while ((line = br.readLine()) != null) {
        if (sb == null)
            sb = new StringBuilder();
...
StringreadFromUrl(String urlString)
Completely reads the content of the given URL as a string.
return new Scanner(new URL(urlString).openStream(), "UTF-8").useDelimiter("\\A").next();
StringreadFromUrl(String urlText)
read From Url
InputStream inputStream = null;
BufferedReader bufferedReader = null;
StringBuilder result = new StringBuilder();
try {
    if (urlText.startsWith("file://")) {
        urlText = urlText.replace("file://", "");
        try {
            inputStream = new FileInputStream(urlText);
...
StringreadFromURL(URL url)
read From URL
InputStream is = url.openStream();
InputStreamReader inputStreamReader = new InputStreamReader(is, "UTF-8");
StringBuffer buffer = new StringBuffer();
char[] cbuf = new char[256];
int len;
do {
    len = inputStreamReader.read(cbuf);
    if (len > 0) {
...
byte[]readFromUrl(URL url)
read From Url
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[8192];
int i;
try (InputStream is = url.openStream()) {
    while ((i = is.read(buffer)) != -1) {
        baos.write(buffer, 0, i);
return baos.toByteArray();
MapreadGOMappingFile(URL filename, Set secondAttributeList)
read GO Mapping File
Map<String, String> ret = new HashMap<String, String>();
try {
    BufferedReader in = new BufferedReader(new InputStreamReader(filename.openStream()));
    String inputLine = in.readLine();
    while ((inputLine = in.readLine()) != null) {
        String[] retail = inputLine.split("\t");
        if (retail.length >= 2) {
            if (secondAttributeList.contains(retail[1].trim()))
...