Apache Commons IO to download website content from URI using IOUtils

Java Code Examples for org.apache.commons.io.IOUtils.toString()

Below Java code example to show you how to use Apache Commons IO IOUtils class to download website content from java.net.URI.

package simplesolution.dev;

import org.apache.commons.codec.Charsets;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class IOUtilToStringFromURIExample {

    public static void main(String... args) {
        try {
            URI uri = new URI("https://simplesolution.dev/");
            String content = IOUtils.toString(uri, Charsets.UTF_8);

        } catch (URISyntaxException ex) {
        } catch (IOException ex) {

Happy Coding 😊