code: protected static ByteArrayWriter createByteArrayWriter(final String fileName, final boolean append, final boolean buffered,
  		final boolean threadSafe, final boolean shared) throws FileNotFoundException {
  		File file = new File(fileName).getAbsoluteFile();
  		file.getParentFile().mkdirs();
  
  		FileOutputStream stream = new FileOutputStream(file, append);
  		ByteArrayWriter writer = shared ? new LockedFileOutputStreamWriter(stream) : new OutputStreamWriter(stream);
  
  		if (buffered) {
  			writer = new BufferedWriterDecorator(writer);
  		}
  
  		if (threadSafe) {
  			writer = new SynchronizedWriterDecorator(writer, stream);
  		}
  
  		return writer;
  	}
docs: Creates a {@link ByteArrayWriter} for a file.
  
  @param fileName
  Name of file to open for writing
  @param append
  An already existing file should be continued
  @param buffered
  Output should be buffered
  @param threadSafe
  Created writer must be thread-safe
  @param shared
  Output file is shared with other processes
  @return Writer for writing to passed file
  @throws FileNotFoundException
  File does not exist or cannot be opened for any other reason