String extension = codec.getDefaultExtension();
compressedPath = path.suffix(extension);
if (fs.exists(compressedPath)) {
throw new AlreadyExistsStorageException(compressedPath);
}
fos = fs.create(compressedPath);
deflateFilter = codec.createOutputStream(fos, compressor);
outputStream = new DataOutputStream(deflateFilter);
} else {
if (fs.exists(path)) {
throw new AlreadyExistsStorageException(path);
}
fos = fs.create(path);
outputStream = new DataOutputStream(new BufferedOutputStream(fos));
}