title: Show graphic progress while copying files using File Channels
body: <p>I am new to Swing Applications.</p>
  
  <p>I have a simple app that copies files from a directory to another one. To copy the files I use <code>FileChannel</code> instances. I was wondering if it is possible to show a progress bar to inform the user How much of the files have been copied.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class Foo extends JFrame{
      long size;
      FileChannel inp = null,
                  outp= null;
      File sourceFile = new File("C:/test/movie.mkv"),
             destFile = new File("C:/output/movie.mkv");
      public void createUI(){
          JPanel panel = new JPanel();
          JButton btn = new JButton("Copy Files");
          panel.add(btn);
          /*code to create and position the jframe*/
          btn.addActionListener((e)-&gt;{
              try {
                  inp = new FileInputStream(sourceFile).getChannel();
                  outp = new FileOutputStream(destFile).getChannel();
                  size = inp.size();
                  outp.transferFrom(inp,0,size);
              } catch (Exception e2) {
                  System.out.println("FIle not found");
                  return;
              }
          });
      }
      public static void main(String[] args) {
          SwingUtilities.invokeLater(()-&gt;new Foo().createUI());
      }
  }
  </code></pre>