How to create file object from URL object (image)
Since Java 7
File file = Paths.get(url.toURI()).toFile();
Use Apache Common IO's FileUtils
:
import org.apache.commons.io.FileUtils
FileUtils.copyURLToFile(url, f);
The method downloads the content of url
and saves it to f
.