Copy codeThe Code is as follows:
Public static String getBrowser (String userAgent ){
If (userAgent = null | userAgent. trim (). length () <1 ){
Return "unknow ";
}
String [] brorserEN = new String [] {
"MyIE2 ",
"Firefox ",
"KuGooSoft ",
"LBBROWSER ",
"TheWord ",
"QQ ",
"Maxthon ",
"BIDUPlayerBrowser ",
"Opera ",
"Chrome ",
"Safari ",
"9A334 ",
"UCWEB ",
"Googlebot ",
"Rv 11.0 "};
String [] brorserCN = new String [] {
"MyIE2 ",
"Firefox ",
"Cool dog ",
"Cheetah ",
"Window of the world ",
"QQ ",
"Maxthon ",
"Baidu audio and video ",
"Opera ",
"Chrome ",
"Safari ",
"360 ",
"UCWEB ",
"Googlebot ",
"Internet Explorer 11.0 "};
For (int I = 0; I <brorserEN. length; I ++ ){
If (userAgent. indexOf (brorserEN [I])>-1 ){
Return brorserCN [I];
}
}
If (userAgent. indexOf ("MSIE")>-1 ){
If (userAgent. indexOf ("MSIE 9.0")>-1 ){
Return "Internet Explorer 9.0 ";
} Else if (userAgent. indexOf ("MSIE 10.0")>-1 ){
Return "Internet Explorer 10.0 ";
} Else if (userAgent. indexOf ("MSIE 8.0")>-1 ){
Return "Internet Explorer 8.0 ";
} Else if (userAgent. indexOf ("MSIE 7.0")>-1 ){
Return "Internet Explorer 7.0 ";
} Else if (userAgent. indexOf ("MSIE 6.0")>-1 ){
Return "Internet Explorer 6.0 ";
}
Return "IE ";
}
Return "unknow Browser ";
}