51Degrees-Java
Mobile Device Detection for Java - 4 Step Setup - 3 minutes
... fiftyone.mobile.detection.factories.StreamFactory;
4) Use the following code to start detecting devices:
//The Lite data file is provided with every archive.
Provider p = new Provider(StreamFactory.create("path/to/data/file"));
Match match = p.match("USERAGENT_STRING");
boolean isMobile = match.getValues("IsMobile").toBool();
if(isMobile)
System.out.println("Mobile");
else
System.out.println("Not mobile");