byte[] buffer = new byte[1024];
Directory dir = index.getDirectory();
Directory dest = getDirectory();
String[] files = dir.list();
for (int i = 0; i < files.length; i++) {
InputStream in = dir.openFile(files[i]);
try {
OutputStream out = dest.createFile(files[i]);
try {
long remaining = in.length();
while (remaining > 0) {
int num = (int) Math.min(remaining, buffer.length);
in.readBytes(buffer, 0, num);
out.writeBytes(buffer, num);
remaining -= num;
}
} finally {
out.close();
}
} finally {
in.close();
}
}
}