Created
January 10, 2018 18:09
Revisions
-
fromdev created this gist
Jan 10, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package browser.util; public class BrowserUtil { public static enum BrowserType { INTERNET_EXPLORER, MOZILA_FIREFOX, SAFARI, NETSCAPE, GOOGLE_CHROME, FLOCK, UNKNOWN } /** * Each browser sends a the user-agent field with different content * * * @param userAgent * @return */ public static BrowserType getBrowserType(String userAgent) { if (userAgent != null) { if (userAgent.indexOf("MSIE") != -1) return BrowserType.INTERNET_EXPLORER; else if (userAgent.indexOf("Netscape") != -1) return BrowserType.NETSCAPE; else if (userAgent.indexOf("Chrome") != -1) return BrowserType.GOOGLE_CHROME; else if (userAgent.indexOf("Flock") != -1) return BrowserType.FLOCK; else if (userAgent.indexOf("Safari") != -1) return BrowserType.SAFARI; else if (userAgent.indexOf("Firefox") != -1) return BrowserType.MOZILA_FIREFOX; } return BrowserType.UNKNOWN; } }