Browse Source

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.

pull/8/head
jrtechs 6 years ago
parent
commit
b3205238bd
4 changed files with 9 additions and 1 deletions
  1. +7
    -0
      src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java
  2. +1
    -0
      src/main/java/net/jrtechs/www/utils/ConfigLoader.java
  3. +1
    -0
      src/main/java/net/jrtechs/www/utils/WebScraper.java
  4. +0
    -1
      src/main/java/net/jrtechs/www/webCrawler/FileIO.java

+ 7
- 0
src/main/java/net/jrtechs/www/SteamAPI/APIConnection.java View File

@ -122,6 +122,9 @@ public class APIConnection
String apiData = this.querySteamAPI(this.baseURL + this.friendListURL + String apiData = this.querySteamAPI(this.baseURL + this.friendListURL +
this.apiKey + "&steamid=" + steamid); this.apiKey + "&steamid=" + steamid);
if(apiData.equals(""))
return friendsId; //private url
JSONObject object = new JSONObject(apiData); JSONObject object = new JSONObject(apiData);
if(object.has("friendslist")) if(object.has("friendslist"))
@ -171,6 +174,9 @@ public class APIConnection
String apiResult = this.querySteamAPI(queryUrl); String apiResult = this.querySteamAPI(queryUrl);
if(apiResult.equals(""))
return map;
JSONObject object = new JSONObject(apiResult); JSONObject object = new JSONObject(apiResult);
if(object.has("response")) if(object.has("response"))
@ -262,6 +268,7 @@ public class APIConnection
{ {
APIConnection con = new APIConnection(); APIConnection con = new APIConnection();
//steam id of jrtechs
con.getFriends("76561198188400721").forEach(System.out::println); con.getFriends("76561198188400721").forEach(System.out::println);
System.out.println(con.getPlayerName("76561198188400721")); System.out.println(con.getPlayerName("76561198188400721"));

+ 1
- 0
src/main/java/net/jrtechs/www/utils/ConfigLoader.java View File

@ -59,6 +59,7 @@ public class ConfigLoader
jsonString += line; jsonString += line;
} }
} }
br.close();
} }
catch(Exception e) catch(Exception e)
{ {

+ 1
- 0
src/main/java/net/jrtechs/www/utils/WebScraper.java View File

@ -114,6 +114,7 @@ public class WebScraper
{ {
html += line; html += line;
} }
br.close();
return html; return html;
} }
} }

+ 0
- 1
src/main/java/net/jrtechs/www/webCrawler/FileIO.java View File

@ -57,7 +57,6 @@ public class FileIO
public boolean playerExists(String id) public boolean playerExists(String id)
{ {
String fileName = baseFilePath + id + ".json"; String fileName = baseFilePath + id + ".json";
return new File(fileName).isFile(); return new File(fileName).isFile();
} }

Loading…
Cancel
Save