diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/HttpUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/HttpUtil.java index 68f4a4c0e..55972eb1e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/HttpUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/HttpUtil.java @@ -10,30 +10,18 @@ import java.net.URL; public class HttpUtil { public static String readUrl(String urlString) { - BufferedReader reader = null; - try { - URL url = new URL(urlString); - reader = new BufferedReader(new InputStreamReader(url.openStream())); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()))){ StringBuilder buffer = new StringBuilder(); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) { buffer.append(chars, 0, read); } - return buffer.toString(); } catch (IOException e) { if (Settings.DEBUG) { e.printStackTrace(); } - } finally { - try { - if (reader != null) { - reader.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } } return null; }