public void downloadFile(final URL downloadURL, final File pathToDownload) throws IOException
    {
        if (mainWorker != null && !mainWorker.isCancelled())
        {
            textArea.append("Downloading newest pack...\n");
            if (currVer == 0)
            {
                getLatestVersionFromURL(new URL(Settings.jenkinsURL));
            }
            final int blk_size = 8192;
            try
            {
                URLConnection con = downloadURL.openConnection();
                InputStream reader = downloadURL.openStream();
                FileOutputStream writer = new FileOutputStream(pathToDownload);
                int total = con.getContentLength();
                int size_dl = 0;
                byte[] buffer = new byte[blk_size];
                int bytesRead = 0;
                while ((bytesRead = reader.read(buffer)) > 0 && !mainWorker.isCancelled())
                {
                    size_dl += bytesRead;
                    // System.out.println((size_dl / total * 100) + "%");
                    progressBar.setString((size_dl / total * 100) + "%");
                    progressBar.setValue(size_dl / total * 100);
                    lblProgressPercent.setText(size_dl + "B out of " + total + "B");
                    writer.write(buffer, 0, bytesRead);
                    buffer = new byte[blk_size];
                }
                writer.close();
                reader.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }