-
-
Save jezinka/7b6158e7320136686f5b0ad59c19eac2 to your computer and use it in GitHub Desktop.
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
private String makeOdjazdQuery(URL url) { | |
if (url != null) { | |
try { | |
return getResponseFromHttpUrl(url); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
return ""; | |
} | |
private static String getResponseFromHttpUrl(URL url) throws IOException { | |
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); | |
try { | |
InputStream in = urlConnection.getInputStream(); | |
Scanner scanner = new Scanner(in); | |
scanner.useDelimiter("\\A"); | |
boolean hasInput = scanner.hasNext(); | |
if (hasInput) { | |
return scanner.next(); | |
} else { | |
return null; | |
} | |
} finally { | |
urlConnection.disconnect(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment