TextWriter writer = new TextWriter();
StreamFactory output;
try {
if(out == null) {
output = new SingleStreamOutput(gzip);
}
else if(out.exists()) {
if(out.isDirectory()) {
if(warnoverwrite && out.listFiles().length > 0) {
logger.warning("Output directory specified is not empty. Files will be overwritten and old files may be left over.");
}
output = new MultipleFilesOutput(out, gzip);
}
else {
if(warnoverwrite) {
logger.warning("Output file exists and will be overwritten!");
}
output = new SingleStreamOutput(out, gzip);
}
}
else {
// If it doesn't exist yet, make a MultipleFilesOutput.
output = new MultipleFilesOutput(out, gzip);