forked from eunbeek/findBrokenGlass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eunbee Kim
committed
Oct 6, 2020
1 parent
97cbea3
commit f84d593
Showing
8 changed files
with
83 additions
and
15 deletions.
There are no files selected for viewing
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
|
||
import org.json.simple.JSONObject; | ||
|
||
public class ConvertJavaToJson { | ||
|
||
public static JSONObject availableURL(String host) | ||
{ | ||
|
||
try { | ||
// request url | ||
URL url = new URL(host); | ||
URLConnection con; | ||
con = url.openConnection(); | ||
|
||
// response | ||
HttpURLConnection exitCode = (HttpURLConnection) con; | ||
exitCode.setInstanceFollowRedirects(true); | ||
HttpURLConnection.setFollowRedirects(true); | ||
exitCode.setConnectTimeout(1000); | ||
|
||
return ConvertJavaObjectToJson(host, exitCode.getResponseCode()); | ||
|
||
}catch (Exception e) { | ||
|
||
return ConvertJavaObjectToJson(host, 599); | ||
} | ||
|
||
|
||
} | ||
|
||
public static JSONObject ConvertJavaObjectToJson(String url, int code) | ||
{ | ||
JSONObject obj = new JSONObject(); | ||
obj.put("url",url); | ||
obj.put("status",code); | ||
|
||
return obj; | ||
|
||
} | ||
} |
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