Directory dest = getDirectory();
String[] files = dir.list();
for (int i = 0; i < files.length; i++) {
IndexInput in = dir.openInput(files[i]);
try {
IndexOutput out = dest.createOutput(files[i]);
try {
long remaining = in.length();
while (remaining > 0) {
int num = (int) Math.min(remaining, buffer.length);
in.readBytes(buffer, 0, num);