Skip to content

Commit

Permalink
No internet connection resolve
Browse files Browse the repository at this point in the history
Adding checking is no internet connection,
if there is no internet "EMPTY" will be return
  • Loading branch information
Damian Panasiuk committed Feb 26, 2021
1 parent 3d1b69c commit 26f271c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Binary file modified library/SjpApi.jar
Binary file not shown.
28 changes: 17 additions & 11 deletions src/CurlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,34 @@ public void run() {
}




private String read(String https) throws IOException {

String curlOutput = "";
HttpURLConnection urlConnection = null;
URL url = new URL(https);


urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();

curlOutput += urlConnection.getResponseCode();
urlConnection.setReadTimeout(500);
urlConnection.setDefaultUseCaches(false);
urlConnection.setUseCaches(false);
try {
urlConnection.connect();
curlOutput += urlConnection.getResponseCode();

BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuilder sb = new StringBuilder();

String line;
while ((line = br.readLine()) != null) {
curlOutput += line + " ";
String line;
while ((line = br.readLine()) != null) {
curlOutput += line + " ";
}
br.close();
}
catch(Exception e) {
curlOutput = "";
}
br.close();

return curlOutput;
}
Expand Down

0 comments on commit 26f271c

Please sign in to comment.