From b3205238bd9d875fc347689f444d80bff331fb42 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 25 Nov 2018 21:18:17 -0500 Subject: [PATCH] Fixed IO issues where some files were not closed and had the API Connection deal with empty strings in the get friends and get names functions. --- src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java | 7 +++++++ src/main/java/net/jrtechs/www/utils/ConfigLoader.java | 1 + src/main/java/net/jrtechs/www/utils/WebScraper.java | 1 + src/main/java/net/jrtechs/www/webCrawler/FileIO.java | 1 - 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java b/src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java index 857526f..f2be238 100644 --- a/src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java +++ b/src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java @@ -122,6 +122,9 @@ public class APIConnection String apiData = this.querySteamAPI(this.baseURL + this.friendListURL + this.apiKey + "&steamid=" + steamid); + if(apiData.equals("")) + return friendsId; //private url + JSONObject object = new JSONObject(apiData); if(object.has("friendslist")) @@ -171,6 +174,9 @@ public class APIConnection String apiResult = this.querySteamAPI(queryUrl); + if(apiResult.equals("")) + return map; + JSONObject object = new JSONObject(apiResult); if(object.has("response")) @@ -262,6 +268,7 @@ public class APIConnection { APIConnection con = new APIConnection(); + //steam id of jrtechs con.getFriends("76561198188400721").forEach(System.out::println); System.out.println(con.getPlayerName("76561198188400721")); diff --git a/src/main/java/net/jrtechs/www/utils/ConfigLoader.java b/src/main/java/net/jrtechs/www/utils/ConfigLoader.java index 8cd748f..50d4b44 100644 --- a/src/main/java/net/jrtechs/www/utils/ConfigLoader.java +++ b/src/main/java/net/jrtechs/www/utils/ConfigLoader.java @@ -59,6 +59,7 @@ public class ConfigLoader jsonString += line; } } + br.close(); } catch(Exception e) { diff --git a/src/main/java/net/jrtechs/www/utils/WebScraper.java b/src/main/java/net/jrtechs/www/utils/WebScraper.java index c880cb1..a4809fc 100644 --- a/src/main/java/net/jrtechs/www/utils/WebScraper.java +++ b/src/main/java/net/jrtechs/www/utils/WebScraper.java @@ -114,6 +114,7 @@ public class WebScraper { html += line; } + br.close(); return html; } } \ No newline at end of file diff --git a/src/main/java/net/jrtechs/www/webCrawler/FileIO.java b/src/main/java/net/jrtechs/www/webCrawler/FileIO.java index ca6b444..93b3bcb 100644 --- a/src/main/java/net/jrtechs/www/webCrawler/FileIO.java +++ b/src/main/java/net/jrtechs/www/webCrawler/FileIO.java @@ -57,7 +57,6 @@ public class FileIO public boolean playerExists(String id) { String fileName = baseFilePath + id + ".json"; - return new File(fileName).isFile(); }