从用户代理获取浏览器版本
// 来自 nowjava import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; public class Main{ public static String getBrowserVersionFromUserAgent(String userAgent, String browser) { if (StringUtil.isEmpty(browser)) return ""; if (StringUtil.isEmpty(userAgent)) return ""; userAgent = userAgent.toLowerCase();/**from N o w J a v a . c o m - 时 代 Java**/ int length = userAgent.length(); int begin = -1; String versionKey = browser; if (browser.equals("safari")) versionKey = "version"; begin = userAgent.indexOf(versionKey); if (begin == -1) return ""; begin = begin + versionKey.length(); int end = begin + 2; for (int i = 2; i < 50; i++) { if ((begin + i) >= userAgent.length()) break; char value = userAgent.charAt(begin + i); if (value == '/' || value == ';' || value ==