Instantly share code, notes, and snippets.

Embed
What would you like to do?
Java
package com.teamextension.ping;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class UrlPing {
public static void main(String[] args) {
String urlString = "http://pshmn.com/eaFnY";
pingUrl(urlString);
}
private static void pingUrl(String urlString) {
try {
URLConnection conn = new URL(urlString).openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
InputStream is = conn.getInputStream();
is.close();
} catch (Exception e) {
// log error
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment