Here you can find the source of VersionComparer(String a, String b, boolean includeEqual)
public static boolean VersionComparer(String a, String b, boolean includeEqual)
//package com.java2s; /*/*from w w w .j ava 2 s .c o m*/ * Copyright 2013 etao.com All right reserved. This software is the * confidential and proprietary information of etao.com ("Confidential * Information"). You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with etao.com . */ public class Main { public static boolean VersionComparer(String a, String b, boolean includeEqual) { if (a == null || b == null) { return false; } String regex = "^([0-9]+\\.)+([0-9]+)$"; if (!a.matches(regex) || !b.matches(regex)) { return false; } if (a.equals(b)) { return includeEqual; } String as[] = a.split("\\."); String bs[] = b.split("\\."); int i = 0; while (as.length > i && bs.length > i) { int ai = Integer.parseInt(as[i]); int bi = Integer.parseInt(bs[i]); if (ai > bi) { return true; } if (ai < bi) { return false; } i++; } while (as.length > i) { int ai = Integer.parseInt(as[i]); if (ai > 0) { return true; } i++; } return false; } }