添加文件获取和判断是否存在接口

This commit is contained in:
zhaojun1998
2020-01-05 15:54:59 +08:00
parent 31dbb902c3
commit f128882034

View File

@@ -1,5 +1,6 @@
package im.zhaojun.common.util;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
/**
@@ -13,4 +14,15 @@ public class HttpUtil {
return result == null ? "" : result;
}
public static boolean checkUrlExist(String url) {
RestTemplate restTemplate = SpringContextHolder.getBean(RestTemplate.class);
try {
restTemplate.headForHeaders(url);
return true;
} catch (RestClientException e) {
e.printStackTrace();
}
return false;
}
}