如何检查图像是否存在于特定位置



除了以下代码之外,有没有其他方法可以检查图像是否存在于特定位置?此代码占用的时间太长。

  static boolean isImage(String image_path){  
    InputStream input = null;
    try{
        URL url = new URL(image_path);
        input = url.openStream();
        return  true;
    }catch(Exception ex){
        return  false;
    }
  }

如果您只想检查文件是否存在:

static boolean isImage(String image_path){  
    try{
        File f = new File(image_path);
        return  f.exists();
    }catch(Exception ex){
        return  false;
    }
}

最新更新