@ Nonnull public final ESuccess dumpDatabase ( @ Nonnull @ WillClose final OutputStream aOS ) { ValueEnforcer . notNull ( aOS , "OutputStream" ) ; // Save the DB data to an SQL file try { LOGGER . info ( "Dumping database '" + getDatabaseName ( ) + "' to OutputStream" ) ; try ( final PrintWriter aPrintWriter = new PrintWriter ( new NonBlockingBufferedWriter ( StreamHelper . createWriter ( aOS , StandardCharsets . UTF_8 ) ) ) ) { final DBExecutor aExecutor = new DBExecutor ( this ) ; final ESuccess ret = aExecutor . queryAll ( "SCRIPT SIMPLE" , aCurrentObject -> { if ( aCurrentObject != null ) { // The value of the first column is the script line aPrintWriter . println ( aCurrentObject . get ( 0 ) . getValue ( ) ) ; } } ) ; aPrintWriter . flush ( ) ; return ret ; } } finally { StreamHelper . close ( aOS ) ; } }
Dump the database to the passed output stream and closed the passed output stream .