public void copy(File f, File dir) throws FileNotFoundException, IOException{
        File f2 = new File(dir, f.getName());
        if(f.isDirectory()){
            f2.mkdir();
            String[] files = f.list();
            for(String s : files){
                currentFile = s;
                copy(new File(f, s), new File(dir, f.getName()));
            }
            return;
        }
        
        f2.createNewFile();
        try (InputStream is = new BufferedInputStream(new FileInputStream(f))) {
            int read;
            byte[] buffer = new byte[4096];

            try(OutputStream os = new BufferedOutputStream(new FileOutputStream(f2))){
                while((read = is.read(buffer)) != -1){
                    os.write(buffer, 0, read);
                    if(done) return;
                    speedStat(read);
                }
            }
        }
    }