Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use thread + CommonIO toolkit to download pictures

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the thread + CommonIO toolkit to download pictures. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Public class WebDownloader {public void download (String url,String name) {try {FileUtils.copyURLToFile (new URL (url), new File (name)); / / you need to introduce the CommonIO dependency package (you need to download it from apache's official website)} catch (IOException e) {e.printStackTrace (); System.out.println ("File path does not exist");}} public class ThreadDownload implements Runnable {public String url;public String name Public ThreadDownload (String url, String name) {this.url = url;this.name = name;} @ Override public void run () {WebDownloader wd=new WebDownloader (); wd.download (url,name);} public static void main (String [] args) {ThreadDownload td1=new ThreadDownload ("https://cache.yisu.com/upload/information/20210521/347/251006.jpg","D\\g.jpg"); td1.start () / / the reason for the start error has not been found, and can not be solved}} so much about how to use the thread + CommonIO toolkit to download images. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report