'How to convert https url to File in Java?
I have an https url which is of String format. How can I convert it to File? I tried this but I'm getting error - URI scheme is not "file"
public static File convertURLToFile(String strURL) throws MalformedURLException {
URL url = new URL(strURL);
File file;
try {
file = new File(url.toURI());
} catch (URISyntaxException e) {
String message = "Error in converting url to file";
throw new RuntimeException(message, e);
}
return file;
}
Solution 1:[1]
FileUtils.copyURLToFile
worked well for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user18333852 |