public int Download(String URL, String output, JProgressBar bar)
            throws IOException {

        int retval = 1;
        final URL url;
        final URLConnection conn;
        InputStream is = null;
        OutputStream os = null;

        logger.info("Download-> Url: " + URL + " ,Destination: " + output);
        try {
            url = new URL(URL);
            conn = url.openConnection();
            is = new BufferedInputStream(conn.getInputStream());
            File file = new File(output);
            os = new BufferedOutputStream(new FileOutputStream(file));

            // TODO besser machen
            // TODO CHangelog buggy
            if (bar == null)
                bar = new JProgressBar();

            conn.setConnectTimeout(10000);
            conn.setReadTimeout(10000);
            int size = conn.getContentLength();
            bar.setMaximum(size);

            byte[] chunk = new byte[1024];
            int chunkSize;
            while ((chunkSize = is.read(chunk)) != -1
                    && (stopdownloading == false)) {

                os.write(chunk, 0, chunkSize);
                int temp = bar.getValue() + 1024;
                bar.setValue(temp);
            }

            if (stopdownloading)
                retval = 0;
            else {
                retval = 1;
            }

        } catch (Exception e) {
            System.out.println("- ERROR - while downloading, connecting to mirror...");
            logger.error(e.getMessage());
            Misc.logStacktrace(e);
            retval = -1;
        } finally {
            if (os != null) {
                os.flush(); // Necessary for Java < 6
                os.close();
            }
            if (is != null)
                is.close();
        }

        return retval;
    }