utils/src/main/java/com/streamsets/datacollector/io/DataStore.java
public void commit(OutputStream out) throws IOException {
    // close the stream in order to flush the contents into the disk
    Utils.checkNotNull(out, "Argument output stream cannot be null");
    Utils.checkState(stream == out, "The argument output stream must be the same as the output stream obtained " +
      "from this data store instance");
    out.close();
    Files.move(fileTmp, fileNew);
    LOG.trace("Committing write, move '{}' to '{}'", fileTmp, fileNew);
    Files.move(fileNew, file);
    LOG.trace("Committing write, move '{}' to '{}'", fileNew, file);
    if (Files.exists(fileOld)) {
      Files.delete(fileOld);
      LOG.trace("Committing write, deleting '{}'", fileOld);
    }
    LOG.trace("Committed");
  }
public void commit(OutputStream out) throws IOException {
    // close the stream in order to flush the contents into the disk
    Utils.checkNotNull(out, "Argument output stream cannot be null");
    Utils.checkState(stream == out, "The argument output stream must be the same as the output stream obtained " +
      "from this data store instance");
    out.close();
    Files.move(fileTmp, fileNew);
    LOG.trace("Committing write, move '{}' to '{}'", fileTmp, fileNew);
    Files.move(fileNew, file);
    LOG.trace("Committing write, move '{}' to '{}'", fileNew, file);
    if (Files.exists(fileOld)) {
      Files.delete(fileOld);
      LOG.trace("Committing write, deleting '{}'", fileOld);
    }
    LOG.trace("Committed");
  }
public void commit ( OutputStream out ) throws IOException { // close the stream in order to flush the contents into the disk Utils . checkNotNull ( out , "Argument output stream cannot be null" ) ; Utils . checkState ( stream == out , "The argument output stream must be the same as the output stream obtained " + "from this data store instance" ) ; out . close ( ) ; Files . move ( fileTmp , fileNew ) ; LOG . trace ( "Committing write, move '{}' to '{}'" , fileTmp , fileNew ) ; Files . move ( fileNew , file ) ; LOG . trace ( "Committing write, move '{}' to '{}'" , fileNew , file ) ; if ( Files . exists ( fileOld ) ) { Files . delete ( fileOld ) ; LOG . trace ( "Committing write, deleting '{}'" , fileOld ) ; } LOG . trace ( "Committed" ) ; }
This method must be used to commit contents written to the output stream which is obtained by calling
the {@link #getOutputStream()} method. This method closes the argument output stream.

Example usage:

DataStore dataStore = new DataStore(...);
try (OutputStream os = dataStore.getOutputStream()) {
os.write(..);
dataStore.commit(os);
} catch (IOException e) {
...
} finally {
dataStore.release();
}

@throws IOException
This method must be used to commit contents written to the output stream which is obtained by calling the { @link #getOutputStream () } method . This method closes the argument output stream .