title: How to check if a download process is complete
body: <p>My application will parse a XML file from my web server then download the files. My application will get the contents of "URL" from in XML file and download it using Common-IO's FileUtils. My problem is, how do I know that my download process is done or not. There is a lot of "URL" in my XML file.</p>
  
  <p>Here is some part of my code:</p>
  
  <pre><code>private Proxy proxy = Proxy.NO_PROXY;
      public void downloadLibrary()
          {
              System.out.println("Start downloading libraries from server...");
              try
              {
                  URL resourceUrl = new URL("http://www.example.com/libraries.xml");
                  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  DocumentBuilder db = dbf.newDocumentBuilder();
                  Document doc = db.parse(resourceUrl.openConnection(proxy).getInputStream());
                  NodeList nodeLst = doc.getElementsByTagName("Contents");
                  for (int i = 0; i &lt; nodeLst.getLength(); i++)
                  {
                      Node node = nodeLst.item(i);
  
                      if (node.getNodeType() == 1)
                      {
                          Element element = (Element)node;
                          String key = element.getElementsByTagName("Key").item(0).getChildNodes().item(0).getNodeValue();
                          File f = new File(launcher.getWorkingDirectory(), key);
                          downloadFile("http://www.example.com/" + key, f, "libraries");
                      }
                  }
              }
              catch(Exception e)
              {
                  System.out.println("Error was found when trying to download libraries file " + e);
              }
  
          }
  
          public void downloadFile(final String url, final File path, final String fileName)
          {
              SwingWorker&lt;Void, Void&gt; worker = new SwingWorker&lt;Void, Void&gt;()
              {
                  @Override
                  protected Void doInBackground() throws Exception
                  {
                      launcher.println("Downloading file " + fileName + "...");
                      try
                      {
                          URL fileURL = new URL(url);
                          ReadableByteChannel rbc = Channels.newChannel(fileURL.openStream());
                          FileOutputStream fos = new FileOutputStream(path);
                          fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
                      }
                      catch(Exception e)
                      {
                          System.out.println("Cannot download file : " + fileName + " " + e);
                      }
                      return null;
                  }
                  @Override
                  public void done()
                  {
                      System.out.println(fileName + " had downloaded sucessfully");
  
                  }
              };
              worker.execute();
          }
  </code></pre>