public static int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int i = 0;
        while (i < v1.length && i < v2.length) {
            int num1 = Integer.parseInt(v1[i]), num2 = Integer.parseInt(v2[i]);
            if (num1 < num2)
                return -1;
            else if (num1 > num2)
                return 1;
            ++i;
        }
        if (i < v1.length && Integer.parseInt(v1[i]) != 0)
            return 1;
        else if (i < v2.length && Integer.parseInt(v2[i]) != 0)
            return -1;
        return 0;
    }