}
private void compress() throws IOException {
InputStream in = null;
OutputStream out = null;
CBZip2OutputStream bzout = null;
if (use_stdout) {
bzout = new CBZip2OutputStream(stdout, clevel);
}
for (File file : files) {
if (file.getName().equals("-")) {
processStream(stdin, bzout);
continue;
}
try {
if (use_stdout) {
if ((in = openFileRead(file)) == null) {
rc = 1;
continue;
}
processStream(in, bzout);
continue;
}
try {
File bzfile = new File(file.getAbsolutePath() + ".bz2");
if ((out = openFileWrite(bzfile, true, force)) == null) {
rc = 1;
continue;
}
bzout = new CBZip2OutputStream(out, clevel);
if ((in = openFileRead(file)) == null) {
rc = 1;
continue;
}
processStream(in, bzout);
float sizeDiff = ((float) bzfile.length() / (float) file.length()) * 100;
notice(String.format(fmt_size_diff, file, sizeDiff, bzfile));
if (!keep) file.delete();
} finally {
close(bzout);
}
} finally {
close(in);
}
}
// TEST need to see if this is even necessary, and if it is
// should it be within a finally block
if (use_stdout) {
bzout.close();
}
}