Last active
September 25, 2018 08:36
-
-
Save pushmon/1886329 to your computer and use it in GitHub Desktop.
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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