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; }
Advertisement
Answer
FileUtils.copyURLToFile
worked well for me.