I have files in who I need to record serialized object. I open ObjectOutputStream
for writing in files. If I didn't wrote nothing in file, file content get deleted. I don't want content to be deleted when I make ObjectOutputStream
.
My code (I use Guice),
@Provides
@ArticleSerializationOutputStream
public ObjectOutputStream getArticleObjectOutputStream(Config config) {
ObjectOutputStream out = null;
String fileName = config.getConfigValue(ARTICLE_SNAPSHOT);
try {
out = new ObjectOutputStream(new FileOutputStream(new File(fileName)));
} catch (IOException e) {
String errorMessage = String.format(IO_EXCEPTION_PROBLEM, fileName);
addError(errorMessage);
}
return out;
}