Source:
private void downloadDatabase() { try { String url; if (config.getBoolean("database.show-cities", false)) { url = config.getString("database.download-url-city"); } else { url = config.getString("database.download-url"); } if (url == null || url.isEmpty()) { logger.log(Level.SEVERE, tl("geoIpUrlEmpty")); return; } String licenseKey = config.getString("database.license-key", ""); if (licenseKey == null || licenseKey.isEmpty()) { logger.log(Level.SEVERE, tl("geoIpLicenseMissing")); return; } else { url = url.replace("{LICENSEKEY}", licenseKey); } logger.log(Level.INFO, tl("downloadingGeoIp")); URL downloadUrl = new URL(url); URLConnection conn = downloadUrl.openConnection(); conn.setConnectTimeout(10000); conn.connect(); InputStream input = conn.getInputStream(); OutputStream output = new FileOutputStream(databaseFile); byte[] buffer = new byte[2048]; if (url.contains("gz")) { input = new GZIPInputStream(input); if (url.contains("tar.gz")) { String filename; TarInputStream tarInputStream = new TarInputStream(input); TarEntry entry; while ((entry = tarInputStream.getNextEntry()) != null) { if (!entry.isDirectory()) { filename = entry.getName(); if (filename.substring(filename.length() - 5).equalsIgnoreCase(".mmdb")) { input = tarInputStream; break; } } } } } int length = input.read(buffer); while (length >= 0) { output.write(buffer, 0, length); length = input.read(buffer); } output.close(); input.close(); } catch (MalformedURLException ex) { logger.log(Level.SEVERE, tl("geoIpUrlInvalid"), ex); } catch (IOException ex) { logger.log(Level.SEVERE, tl("connectionFailed"), ex); } }

Target:
private void downloadDatabase() { try { String url; if (config.getBoolean("database.show-cities", false)) { url = config.getString("database.download-url-city"); } else { url = config.getString("database.download-url"); } if (url == null || url.isEmpty()) { logger.log(Level.SEVERE, tl("geoIpUrlEmpty")); return; } String licenseKey = config.getString("database.license-key", ""); if (licenseKey == null || licenseKey.isEmpty()) { logger.log(Level.SEVERE, tl("geoIpLicenseMissing")); return; } url = url.replace("{LICENSEKEY}", licenseKey); logger.log(Level.INFO, tl("downloadingGeoIp")); URL downloadUrl = new URL(url); URLConnection conn = downloadUrl.openConnection(); conn.setConnectTimeout(10000); conn.connect(); InputStream input = conn.getInputStream(); OutputStream output = new FileOutputStream(databaseFile); byte[] buffer = new byte[2048]; if (url.contains("gz")) { input = new GZIPInputStream(input); if (url.contains("tar.gz")) { String filename; TarInputStream tarInputStream = new TarInputStream(input); TarEntry entry; while ((entry = tarInputStream.getNextEntry()) != null) { if (!entry.isDirectory()) { filename = entry.getName(); if (filename.substring(filename.length() - 5).equalsIgnoreCase(".mmdb")) { input = tarInputStream; break; } } } } } int length = input.read(buffer); while (length >= 0) { output.write(buffer, 0, length); length = input.read(buffer); } output.close(); input.close(); } catch (MalformedURLException ex) { logger.log(Level.SEVERE, tl("geoIpUrlInvalid"), ex); } catch (IOException ex) { logger.log(Level.SEVERE, tl("connectionFailed"), ex); } }