Verified Commit 3a78033a authored by AtjonTV's avatar AtjonTV

ffdb: flushToStream function for custom usage of FFDB

parent 9e0839e8
......@@ -3,6 +3,7 @@ package klib.ffdb
import java.io.File
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.OutputStream
import java.lang.Exception
import klib.annotations.Experimental
import klib.exceptions.IncompatibleDatabaseException
......@@ -153,6 +154,24 @@ class FFDB(val storageFile: File, val schemaVersion: Int = Version.V2.version) {
}
}
/**
* Write objects to custom Stream
*
* @param stream Output Stream target
*
* @since 5.0.0
* @author Thomas Obernosterer
*/
fun flushToStream(stream: OutputStream) {
if (writeBuffer.isEmpty()) {
return
}
when (schemaVersion) {
Version.V1.version -> writeV1(ObjectOutputStream(stream))
Version.V2.version -> writeV2(ObjectOutputStream(stream))
}
}
/**
* Clear the internal write buffer
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment