is IE user agent from connection String - Java Network

Java examples for Network:User Agent

Description

is IE user agent from connection String

Demo Code


import org.apache.log4j.Logger;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static void main(String[] argv) throws Exception{
        String userAgent = "java2s.com";
        System.out.println(isIE(userAgent));
    }/*from   www. j a  v a  2  s  . co  m*/
    /**
     * Logger for this class
     */
    private static final Logger logger = Logger
            .getLogger(DownloadHelper.class);
    public static boolean isIE(String userAgent) {
        if (logger.isDebugEnabled()) {
            logger.debug("isIE(String) - start"); //$NON-NLS-1$
        }

        boolean returnboolean = userAgent.toLowerCase().indexOf("msie") > 0 ? true
                : false;
        if (logger.isDebugEnabled()) {
            logger.debug("isIE(String) - end"); //$NON-NLS-1$
        }
        return returnboolean;
    }
}

Related Tutorials