1、公用部分
HttpImageProvider.java
public class HttpImageProvider implements ImageProvider{
@Override
public InputStream getImage(String path){
try(CloseableHttpClient client = HttpClients.createDefault()){
URIBuilder uriBuilder = new URIBuilder(path);
HttpGet httpGet = HttpGet(uriBuilder.build()));
httpGet.setHeader("User-Agent", "Mozilla/5.0(Window NT 10.0; WOW64) AppleWebKit/537.36(KHTML, like GecKo) Chrome/75.0.3370.90 Safari/537.36");
try(CloseableHttpResponse response = client.execute(httpGet)){
File tmp = File.createTempFile("ur-img-", "tmp");
tmp.deleteOnExit();
FileOutputStream out = new FileOutputStream(tmp);
response.getEntity.writeTo(out);
out.flush();
return new BufferedInputStream(new FileInputStream(tmp<