class Utils {

    static void downloadAndInstallAuxdata(Path targetDir, URL remoteZipFileUrl) throws L2AuxDataException {
        final URL fileUrl;
        try {
            fileUrl = remoteZipFileUrl;
            final URLConnection urlConnection;
            if (System.getProperty("http.proxyHost") == null || System.getProperty("http.proxyPort") == null) {
                urlConnection = fileUrl.openConnection();
            } else {
                urlConnection = fileUrl.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort")))));
            }
            InputStream inputStream = urlConnection.getInputStream();
            ZipInputStream zis = new ZipInputStream(inputStream);
            ZipEntry entry;
            while((entry = zis.getNextEntry()) != null) {
                Path filepath = targetDir.resolve(entry.getName());
                if (!entry.isDirectory()) {
                    // if the entry is a file, extracts it
                    Files.copy(zis, filepath);
                } else {
                    // if the entry is a directory, make the directory
                    Files.createDirectories(filepath);
                }
            }
        } catch (IOException e) {
            throw new L2AuxDataException("Not able to download auxiliary data from " + remoteZipFileUrl, e);
        }
    }

    private  Utils();

}