Java implementation of fetching resources from the web