Нужно иметь JProgress бар для измерения прогресса при копировании каталогов и файлов

У меня есть код ниже для копирования каталогов и файлов, но я не уверен, где измерить прогресс. Может кто-нибудь помочь

где я могу измерить, сколько было скопировано и показать это в панели JProgress

public static void copy(File src, File dest)
throws IOException{
if(src.isDirectory()){
        if(!dest.exists()){ //checking whether destination directory exisits
           dest.mkdir();
           System.out.println("Directory copied from " 
                        + src + "  to " + dest);
        }

        String files[] = src.list();

        for (String file : files) {

           File srcFile = new File(src, file);
           File destFile = new File(dest, file);

           copyFolder(srcFile,destFile);
        }
  }else{
        InputStream in = new FileInputStream(src);
          OutputStream out = new FileOutputStream(dest); 

          byte[] buffer = new byte[1024];

          int length;

          while ((length = in.read(buffer)) > 0){
           out.write(buffer, 0, length);
          }

          in.close();
          out.close();
          System.out.println("File copied from " + src + " to " + dest);
  }

Ответы на вопрос(3)

Ваш ответ на вопрос