Java simple versionControl

I have not had much time today but managed to implement a version control function in the calculator that will allow you to check for new version when available as I am constantly improving and changing it will be good if you know when there is a update.

I am still deciding where to run the check automatically every time the calculator starts or add it to the menu and you check whenever you want or both with a flag should you choose not to update at this point in time.


URL version = new URL("http://localhost/version.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(version.openStream()));

String newVersion = in.readLine();
String currentVersion = "1.0.2";

String currentValue = currentVersion.replaceAll("\\.", "");
String newValue = newVersion.replaceAll("\\.", "");

int x = Integer.parseInt(currentValue);
int y = Integer.parseInt(newValue);

if (x == y){
System.out.println("Your Version is up to date!");
} else if (x > y){
System.out.println("ERROR - This is not possible");
} else if (x < y){ System.out.println("New version available for download!"); }


I know this is not the smartest way to do it but it does what I need and works well as long as I stay within the single digit version control "major"."minor"."bugs" The current calculator is available on #fedora #linuxmint #ubuntu and hopefully the new version will be available pre-packed to more distros also. 🙂

Anyway until next time

Leave a Reply