Skip to content

Commit

Permalink
timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Subilan committed Jan 23, 2024
1 parent 76bb5c0 commit 502555a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public static BufferedReader getURLContents(@Nonnull String urlString, @Nonnull
try {
URL url = new URL(urlString);
URLConnection connection = url.openConnection();
connection.setConnectTimeout(3000);
connection.setReadTimeout(3000);
InputStream stream = connection.getInputStream();
InputStreamReader reader = new InputStreamReader(stream);

return new BufferedReader(reader);
} catch (Exception e) { // Malformed URL, Offline, etc.
e.printStackTrace();
Expand Down

0 comments on commit 502555a

Please sign in to comment.