比如一张图片的url为https://aaa.com/1.jpg,要判断该图片是否存在
public boolean getRource(String source) { try { URL url = new URL(source); URLConnection uc = url.openConnection(); InputStream in = uc.getInputStream(); if (source.equalsIgnoreCase(uc.getURL().toString())) in.close(); return true; } catch (Exception e) { return false; } }