diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 17:44:10 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 17:44:10 -0600 |
commit | 65033eee492e0016f88de2d765701bdb854ce330 (patch) | |
tree | 77b95693c711813d6daed3ee32d88136cf8d143f /src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java | |
parent | 1dade4db82b4828a8480fa379d5fb1765002b2d9 (diff) | |
download | resurrection-65033eee492e0016f88de2d765701bdb854ce330.tar resurrection-65033eee492e0016f88de2d765701bdb854ce330.tar.gz resurrection-65033eee492e0016f88de2d765701bdb854ce330.tar.bz2 |
updater should work now
Diffstat (limited to 'src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java')
-rw-r--r-- | src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java index 8a13780..1507480 100644 --- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java +++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java @@ -3,11 +3,9 @@ package net.brysonsteck.Resurrection.startup; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.stream.JsonReader; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -19,11 +17,8 @@ public class CheckForUpdate { public CheckForUpdate() { try { - URL url = new URL("http://resurrect.brysonsteck.net"); - URLConnection request = url.openConnection(); - request.connect(); - JsonParser json = new JsonParser(); - JsonElement root = json.parse(new InputStreamReader((InputStream) request.getContent())); + String json = urlReader(); + JsonElement root = new JsonParser().parse(json); JsonObject rootobj = root.getAsJsonObject(); version = rootobj.get("current-version").getAsString(); versionURL = rootobj.get("release-url").getAsString(); @@ -33,6 +28,24 @@ public class CheckForUpdate { } } + public String urlReader() throws IOException { + URL website = new URL("https://brysonsteck.net/resurrect.json"); + URLConnection connection = website.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + connection.getInputStream())); + + StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = in.readLine()) != null) + response.append(inputLine); + + in.close(); + + return response.toString(); + } + public String getVersionURL() { return versionURL; } |