diff --git a/bin/ConvertJavaToJson.class b/bin/ConvertJavaToJson.class new file mode 100644 index 0000000..b141ca9 Binary files /dev/null and b/bin/ConvertJavaToJson.class differ diff --git a/bin/UrlCheck$1.class b/bin/UrlCheck$1.class new file mode 100644 index 0000000..7f21da9 Binary files /dev/null and b/bin/UrlCheck$1.class differ diff --git a/bin/UrlCheck.class b/bin/UrlCheck.class index f50d0f2..cd19f53 100644 Binary files a/bin/UrlCheck.class and b/bin/UrlCheck.class differ diff --git a/bin/UrlCheckForMac.class b/bin/UrlCheckForMac.class new file mode 100644 index 0000000..07b32e6 Binary files /dev/null and b/bin/UrlCheckForMac.class differ diff --git a/bin/UrlCheckForWindow.class b/bin/UrlCheckForWindow.class new file mode 100644 index 0000000..6e266f8 Binary files /dev/null and b/bin/UrlCheckForWindow.class differ diff --git a/bin/mac/UrlCheck.jar b/bin/mac/UrlCheck.jar index 2ce4fcc..2d295a6 100644 Binary files a/bin/mac/UrlCheck.jar and b/bin/mac/UrlCheck.jar differ diff --git a/bin/window/UrlCheck.exe b/bin/window/UrlCheck.exe index a9b7a40..7cf2309 100644 Binary files a/bin/window/UrlCheck.exe and b/bin/window/UrlCheck.exe differ diff --git a/bin/window/UrlCheck.jar b/bin/window/UrlCheck.jar index 154a640..814f615 100644 Binary files a/bin/window/UrlCheck.jar and b/bin/window/UrlCheck.jar differ diff --git a/src/UrlCheck.java b/src/UrlCheck.java index faa1f12..9b4e538 100644 --- a/src/UrlCheck.java +++ b/src/UrlCheck.java @@ -30,6 +30,8 @@ public class UrlCheck { static JSONArray list = new JSONArray(); + static int Bad = 0; + public static void helpMessage() { System.out.println("========================================================"); @@ -110,6 +112,8 @@ public static void endMessage() { System.out.println("========================================================"); + System.out.println("End Code : " + Bad); + System.out.println("========================================================"); } @@ -150,6 +154,10 @@ public static void fileUrlListUp(String fName, boolean archived, boolean secured { JSONObject temp = new JSONObject(); temp = ConvertJavaToJson.availableURL(str); + if((int)temp.get("status") < 200 || (int)temp.get("status") >= 400) + { + Bad++; + } list.add(temp); } else @@ -159,11 +167,17 @@ public static void fileUrlListUp(String fName, boolean archived, boolean secured if(runMac) { - UrlCheckForMac.availableURL(str); + if(!UrlCheckForMac.availableURL(str)) + { + Bad++; + } } else { - UrlCheckForWindow.availableURL(str); + if(!UrlCheckForWindow.availableURL(str)) + { + Bad++; + } } } // request archived diff --git a/src/UrlCheckForMac.java b/src/UrlCheckForMac.java index 878ee5f..9a3ede2 100644 --- a/src/UrlCheckForMac.java +++ b/src/UrlCheckForMac.java @@ -12,9 +12,10 @@ public class UrlCheckForMac { public static final String RESET = "\033[0m"; // request url and check the response - public static void availableURL(String host) + public static boolean availableURL(String host) { - + boolean result = false; + try { // request url URL url = new URL(host); @@ -31,7 +32,7 @@ public static void availableURL(String host) // // for Mac if(exitCode.getResponseCode() >= 200 && exitCode.getResponseCode() < 300) { - + result = true; System.out.println(GREEN+"["+exitCode.getResponseCode()+"] "+ host +" - Good"+RESET); } @@ -45,7 +46,7 @@ else if(exitCode.getResponseCode() == 301 || exitCode.getResponseCode() == 307 | // redirect to new location by Recursion itself when it is 301,307,308 String newUrl = exitCode.getHeaderField("Location"); - availableURL(newUrl); + result = availableURL(newUrl); } else @@ -58,5 +59,6 @@ else if(exitCode.getResponseCode() == 301 || exitCode.getResponseCode() == 307 | System.out.println(RED+"[599] "+ host +" - Fail" +RESET); } + return result; } } diff --git a/src/UrlCheckForWindow.java b/src/UrlCheckForWindow.java index c654e37..423d110 100644 --- a/src/UrlCheckForWindow.java +++ b/src/UrlCheckForWindow.java @@ -23,8 +23,10 @@ public class UrlCheckForWindow { static final int STD_OUTPUT_HANDLE = -11; // request url and check the response - public static void availableURL(String host) + public static boolean availableURL(String host) { + boolean result = false; + Kernel32 lib = Native.load("kernel32", Kernel32.class); try { @@ -43,7 +45,7 @@ public static void availableURL(String host) // response code result if(exitCode.getResponseCode() >= 200 && exitCode.getResponseCode() < 300) { - + result = true; lib.SetConsoleTextAttribute(lib.GetStdHandle(STD_OUTPUT_HANDLE), GREEN); System.out.println("["+exitCode.getResponseCode()+"] "+ host +" - Good"); lib.SetConsoleTextAttribute(lib.GetStdHandle(STD_OUTPUT_HANDLE), WHITE); @@ -62,7 +64,7 @@ else if(exitCode.getResponseCode() == 301 || exitCode.getResponseCode() == 307 | // redirect to new location by Recursion itself when it is 301,307,308 String newUrl = exitCode.getHeaderField("Location"); - availableURL(newUrl); + result = availableURL(newUrl); } else @@ -78,5 +80,6 @@ else if(exitCode.getResponseCode() == 301 || exitCode.getResponseCode() == 307 | System.out.println("[599] "+ host +" - Fail" ); lib.SetConsoleTextAttribute(lib.GetStdHandle(STD_OUTPUT_HANDLE), WHITE); } + return result; } }