* Initialization
*
* @throws IOException I/O exception
*/
private void init() throws IOException {
IStreamableFileFactory factory = (IStreamableFileFactory) ScopeUtils
.getScopeService(scope, IStreamableFileFactory.class,
StreamableFileFactory.class);
File folder = file.getParentFile();
if (!folder.exists())
if (!folder.mkdirs())
throw new IOException("can't create parent folder");
if (!file.isFile()) {
// Maybe the (previously existing) file has been deleted
file.createNewFile();
} else if (!file.canWrite()) {
throw new IOException("the file is read-only");
}
IStreamableFileService service = factory.getService(file);
IStreamableFile flv = service.getStreamableFile(file);
if (mode == null || mode.equals(IClientStream.MODE_RECORD)) {
writer = flv.getWriter();
} else if (mode.equals(IClientStream.MODE_APPEND)) {
writer = flv.getAppendWriter();