How To Download a Public Resource With Java 7

The following snippet downloads the latest Spring Framework Reference Documentation

This works since Java 7

import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

URL url = new URL("https://docs.spring.io/spring/docs/current/spring-framework-reference/pdf/core.pdf");
InputStream in = url.openStream();
Files.copy(in, Paths.get("spring-framework-reference.pdf"), StandardCopyOption.REPLACE_EXISTING);
in.close();

Kudos to How to download a PDF from a given URL in Java?