We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0bf8da commit 400a336Copy full SHA for 400a336
1 file changed
URL status checker.java
@@ -0,0 +1,16 @@
1
+import java.net.*;
2
+
3
+public class URLChecker {
4
+ public static void main(String[] args) {
5
+ try {
6
+ URL u = new URL("https://www.google.com");
7
+ HttpURLConnection h = (HttpURLConnection) u.openConnection();
8
+ h.setRequestMethod("GET");
9
+ int code = h.getResponseCode();
10
11
+ System.out.println("Status Code: " + code);
12
+ } catch (Exception e) {
13
+ System.out.println("Invalid URL!");
14
+ }
15
16
+}
0 commit comments