public static void copyFiles(OverthereConnection srcHost, OverthereConnection dstHost, List<String> copySpec) {
        if (copySpec.isEmpty()) {
            return;
        }

        if (copySpec.size() % 2 == 0) {
            Iterator<String> toCopy = copySpec.iterator();
            while (toCopy.hasNext()) {
                OverthereFile src = srcHost.getFile(toCopy.next());
                OverthereFile dst = dstHost.getFile(toCopy.next());
                src.copyTo(dst);
            }
        } else {
            List<String> srcFiles = copySpec.subList(0, copySpec.size() - 1);
            OverthereFile dst = dstHost.getFile(copySpec.get(copySpec.size() - 1));

            Iterator<String> toCopy = srcFiles.iterator();
            while (toCopy.hasNext()) {
                OverthereFile src = srcHost.getFile(toCopy.next());
                src.copyTo(dst);
            }
        }
    }
public static void copyFiles ( OverthereConnection srcHost , OverthereConnection dstHost , List < String > copySpec ) { if ( copySpec . isEmpty ( ) ) { return ; } if ( copySpec . size ( ) % 2 == 0 ) { Iterator < String > toCopy = copySpec . iterator ( ) ; while ( toCopy . hasNext ( ) ) { OverthereFile src = srcHost . getFile ( toCopy . next ( ) ) ; OverthereFile dst = dstHost . getFile ( toCopy . next ( ) ) ; src . copyTo ( dst ) ; } } else { List < String > srcFiles = copySpec . subList ( 0 , copySpec . size ( ) - 1 ) ; OverthereFile dst = dstHost . getFile ( copySpec . get ( copySpec . size ( ) - 1 ) ) ; Iterator < String > toCopy = srcFiles . iterator ( ) ; while ( toCopy . hasNext ( ) ) { OverthereFile src = srcHost . getFile ( toCopy . next ( ) ) ; src . copyTo ( dst ) ; } } }
Copy files from srcHost to dstHost. Files are copied using overthere. So from file to file or from directory to
directory. If copySpec's length is even then files/directories are copied pair wise. If copySpec's lenght is odd
then everything is copied into the last entry.