简体   繁体   English

如何在Java中缓存从URL下载的图像?

[英]How to cache image downloaded from URL in Java?

I have downloaded an image from a URL using ImageIO.write, so now I am wondering if there was a possibility of somehow caching that image. 我已经使用ImageIO.write从URL下载了图像,所以现在我想知道是否存在以某种方式缓存该图像的可能性。 Is there a possibility to compare the downloaded image with the URL it's downloaded from to know that the image is from that URL? 是否可以将下载的图像与下载的URL进行比较,以了解该图像来自该URL? I need this because if I download an image and than later call that same URL for downloading, my app can recognize that it already has the image downloaded, so it doesn't download it again. 我之所以需要这样做,是因为如果我下载图像,然后又调用了相同的URL进行下载,则我的应用程序可以识别出它已经下载了图像,因此不会再次下载。

You should try to see if you can integrate the code to upload the picture to google and search by image. 您应该尝试看看是否可以集成代码以将图片上传到Google并按图片搜索。 Or, you can also save the url of the image with an array while storing the image if you have multiple images you want to download at once. 或者,如果要一次下载多个图像,则在存储图像时也可以使用数组保存图像的url。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM