mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
30 lines
804 B
Java
30 lines
804 B
Java
package im.zhaojun.common.util;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.client.RestClientException;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
/**
|
|
* @author zhaojun
|
|
*/
|
|
@Slf4j
|
|
public class HttpUtil {
|
|
|
|
public static String getTextContent(String url) {
|
|
RestTemplate restTemplate = SpringContextHolder.getBean("restTemplate");
|
|
String result = restTemplate.getForObject(url, String.class);
|
|
return result == null ? "" : result;
|
|
}
|
|
|
|
public static boolean checkUrlExist(String url) {
|
|
RestTemplate restTemplate = SpringContextHolder.getBean("restTemplate");
|
|
try {
|
|
restTemplate.headForHeaders(url);
|
|
return true;
|
|
} catch (RestClientException ignored) {
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|