除了下面的代码之外,还有什么方法可以检查图像是否存在于特定位置?此代码花费了太多时间。
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;
}
}
关于java - 如何检查图像是否存在于特定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28360505/