try {
Collection<String> files = getFiles();
listener.notifyProcessingCount(files.size());
byte b[] = new byte[512];
ZipOutputStream zout = getZipOutputStream(directory.toString());
if (zout != null) {
ZipEntry versionEntry = new ZipEntry("version.txt");
zout.putNextEntry(versionEntry);
String version = String.valueOf(DataCrow.getVersion().toString());
zout.write(version.getBytes(), 0, version.getBytes().length);
if (comment.length() > 0)
zout.write(("\n" + comment).getBytes(), 0, ("\n" + comment).getBytes().length);
zout.closeEntry();
for (String file : files) {
if (!file.endsWith(".log")) {
InputStream in = new FileInputStream(file);
ZipEntry e = new ZipEntry(file.replace(File.separatorChar, '/'));
zout.putNextEntry(e);
int len = 0;
while ((len = in.read(b)) != -1) {
zout.write(b, 0, len);
}
listener.sendMessage(DcResources.getText("msgCreatingBackupOfFile", file));
in.close();
zout.closeEntry();
}
listener.notifyProcessed();
}
zout.close();
listener.sendMessage(DcResources.getText("msgWritingBackupFile"));
}
} catch (Exception e) {
listener.sendMessage(DcResources.getText("msgBackupError", e.getMessage()));
listener.sendError(e);