public static void downloadLocalCopy(String localFile,String urlString) { try { URL url = new URL(urlString); try(InputStream in = url.openStream()){ Files.copy(in, Paths.get(localFile)); } } catch (Exception e) { e.printStackTrace(); } }Sample usage: downloadLocalCopy("mycopy.png","https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");
Yes, this came from a stackoverflow post.
No comments:
Post a Comment