Skip to content

Instantly share code, notes, and snippets.

@pushmon
Last active September 25, 2018 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pushmon/1886329 to your computer and use it in GitHub Desktop.
Save pushmon/1886329 to your computer and use it in GitHub Desktop.
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