java 判断是否大于指定版本号
判断 a.b.c 格式的版本大小:
public boolean is_version_great_than(String version) { boolean result = false; if (!StringUtil.isNullorEmpty(version) && version.indexOf(".") >= 0) { String[] version_num = version.split("\\."); //必须转义 String[] cur_num = clientVersion.split("\\."); int loop_count = version_num.length; if (cur_num.length < version_num.length) { loop_count = cur_num.length; } for (int i = 0; i < loop_count; i++) { if (Integer.valueOf(cur_num[i]) > Integer.valueOf(version_num[i])) { // 当有一节大于就跳出 result = true; break; } } } return result; }
结论: