code: public static <T extends Serializable> Observable<T> write(final Observable<T> source,
              final File file, final boolean append, final int bufferSize) {
          Func0<ObjectOutputStream> resourceFactory = new Func0<ObjectOutputStream>() {
              @Override
              public ObjectOutputStream call() {
                  try {
                      return new ObjectOutputStream(new BufferedOutputStream(
                              new FileOutputStream(file, append), bufferSize));
                  } catch (FileNotFoundException e) {
                      throw new RuntimeException(e);
                  } catch (IOException e) {
                      throw new RuntimeException(e);
                  }
              }
          };
          Func1<ObjectOutputStream, Observable<? extends T>> observableFactory = new Func1<ObjectOutputStream, Observable<? extends T>>() {
  
              @Override
              public Observable<? extends T> call(ObjectOutputStream oos) {
                  return write(source, oos);
              }
          };
          Action1<ObjectOutputStream> disposeAction = new Action1<ObjectOutputStream>() {
  
              @Override
              public void call(ObjectOutputStream oos) {
                  try {
                      oos.close();
                  } catch (IOException e) {
                      throw new RuntimeException(e);
                  }
              }
          };
          return Observable.using(resourceFactory, observableFactory, disposeAction, true);
      }
docs: Writes the source stream to the given file in given append mode and using
  the given buffer size.
  
  @param source
  observable stream to write
  @param file
  file to write to
  @param append
  if true writes are appended to file otherwise overwrite the
  file
  @param bufferSize
  the buffer size in bytes to use.
  @param <T>
  the generic type of the input stream
  @return re-emits the input stream