import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class ImageUtil {
/**
* 判断网络图片是否存在 posturl 图片地址链接
*/
public static String isImagesTrue(String posturl) throws IOException {
URL url = new URL(posturl);
HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
urlcon.setRequestMethod("POST");
urlcon.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
if (urlcon.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println(HttpURLConnection.HTTP_OK + posturl + ":posted ok!");
return "200";
} else {
System.out.println(urlcon.getResponseCode() + posturl + ":Bad post...");
return "404";
}
}
}