Java URL Load 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) throws IOException 

Method Source Code


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

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class Main {
    public static String readFile(URL url) throws IOException {
        InputStream in = url.openStream();
        ByteArrayDataOutput bout = ByteStreams.newDataOutput();
        int b;/*from w w w. j  a va  2 s .com*/
        while ((b = in.read()) != -1) {
            bout.writeByte(b);
        }
        in.close();
        return new String(bout.toByteArray());
    }
}

Related

  1. readContentsToList(URL url)
  2. readContentsToString(URL url)
  3. readData(String url)
  4. readFile(URL file)
  5. readFile(URL url)
  6. readFileContent(URL file)
  7. readFileFromURL(URL url)
  8. readFileIntoMap(URL url)
  9. readFileIntoString(URL input)