if (os == null) {
os = new ByteArrayOutputStream();
}
try {
if (!newFile.createNewFile()) {
throw new FsException("unable to create file");
}
try {
FileOutputStream fs = new FileOutputStream(newFile);
fs.write(os.toByteArray());
fs.flush();
fs.close();
} catch (Exception ee) {
newFile.delete();
throw new FsException("unable to write file");
}
} catch (Exception e) {
throw new FsException("unable to create file");
}
}