jPaq can do this for you with minimal code. The documentation can be found here: http://jpaq.org/documentation/jPaq.GET/1.0/. To download the smallest library which supplies this functionality, I would definitely use jPaq: http://jpaq.org/download/1.0.0.O.