sample working code will be difficult but there is a great library by apache http client.
http://www.mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/
http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples
you can find many example on these sites