[英]How to check image exist in a particular location?
Is there any way to check image exist in a particular location except the following code?This code is taking too much time. 除了以下代码,是否有任何方法可以检查特定位置的图像?此代码花费了太多时间。
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;
}
}
If you just want to check if the file exists: 如果只想检查文件是否存在:
static boolean isImage(String image_path){
try{
File f = new File(image_path);
return f.exists();
}catch(Exception ex){
return false;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.