Apache Commons IO to download website content from URL 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.URL.

package simplesolution.dev;

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

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

public class IOUtilToStringFromURLExample {

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

        } catch (IOException ex) {

Happy Coding 😊