is Apple Webkit user agent - Java Network

Java examples for Network:User Agent

Description

is Apple Webkit user agent

Demo Code


import java.util.Map;
import javax.faces.context.FacesContext;

public class Main{
    public static void main(String[] argv) throws Exception{
        System.out.println(isAppleWebkit());
    }//from   w  w  w .  j  av  a2  s . c o m
    public static boolean isAppleWebkit() {
        // both Opera and Google Chrome does not like CData
        final Map<String, String> headerMap = FacesContext
                .getCurrentInstance().getExternalContext()
                .getRequestHeaderMap();
        final String userAgent = headerMap.get("User-Agent");
        return userAgent != null && userAgent.indexOf("AppleWebKit") > -1;
    }
}

Related Tutorials