public static int compareVersion(String version1, String version2) {
    	String s1=version1, s2=version2;
    	int i=0, j=0, m=s1.length(), n=s2.length();
    	while (i<m&&s1.charAt(i)!='.')
    		++i;
    	while (j<n&&s2.charAt(j)!='.')
    		++j;
    	int rel=compareString(s1.substring(0, i), s2.substring(0, j));
    	if (rel!=0)
    		return rel;
    	return compareString(s1.substring(i), s2.substring(j));
    }