code: private byte[] downloadTile(String zoomUrl, URL url, int z, long x, long y) {
  
  		byte[] bytes = null;
  
  		HttpURLConnection connection = null;
  		try {
  			connection = (HttpURLConnection) url.openConnection();
  			connection.connect();
  
  			int responseCode = connection.getResponseCode();
  			if (responseCode == HttpURLConnection.HTTP_MOVED_PERM
  					|| responseCode == HttpURLConnection.HTTP_MOVED_TEMP
  					|| responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
  				String redirect = connection.getHeaderField("Location");
  				connection.disconnect();
  				url = new URL(redirect);
  				connection = (HttpURLConnection) url.openConnection();
  				connection.connect();
  			}
  
  			if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
  				throw new GeoPackageException("Failed to download tile. URL: "
  						+ zoomUrl + ", z=" + z + ", x=" + x + ", y=" + y
  						+ ", Response Code: " + connection.getResponseCode()
  						+ ", Response Message: "
  						+ connection.getResponseMessage());
  			}
  
  			InputStream geoPackageStream = connection.getInputStream();
  			bytes = GeoPackageIOUtils.streamBytes(geoPackageStream);
  
  		} catch (IOException e) {
  			throw new GeoPackageException("Failed to download tile. URL: "
  					+ zoomUrl + ", z=" + z + ", x=" + x + ", y=" + y, e);
  		} finally {
  			if (connection != null) {
  				connection.disconnect();
  			}
  		}
  
  		return bytes;
  	}
docs: Download the tile from the URL
  
  @param zoomUrl
  @param url
  @param z
  @param x
  @param y
  @return tile bytes