I'm trying to make an update checker for a game, where it reads the latest update version from a file online and notifies the user if the version is higher than the current version of the game.
The version file is fully public on Dropbox and contains only the number 2.
This is what I'm currently trying:
public static int getVersionFromCloud()
{
int version = -1;
try
{
URL link = new URL("https://www.dropbox.com/s/1jeuy4v1w46ccn6/launcher.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(link.openStream()));
System.out.println(reader.readLine());
version = Integer.parseInt(reader.readLine());
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
return version;
}
But I get this error:
// From System.out.println()
<!DOCTYPE html><html lang="en" xmlns:fb="http://ogp.me/ns/fb#" xml:lang="en" class="" xmlns="http://www.w3.org/1999/xhtml">
// Error
Exception in thread "main" java.lang.NumberFormatException: For input string: "<head><script type="text/javascript" nonce="CYFUWuYzTUo6rNiFN6N4">"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at data.io.Util.getVersionFromCloud(Util.java:21)
at data.LauncherBasic.updateFields(LauncherBasic.java:104)
at data.LauncherBasic.<init>(LauncherBasic.java:55)
at data.LauncherBasic.main(LauncherBasic.java:43)
I've also tried this, but it always returns null.