Debe tener una barra de JProgress para medir el progreso al copiar directorios y archivos
Tengo el siguiente código para copiar directorios y archivos, pero no estoy seguro de dónde medir el progreso. Alguien puede ayudar
en cuanto a dónde puedo medir cuánto se ha copiado y mostrarlo en la barra de 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);
}