aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java')
-rw-r--r--org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java b/org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java
index f6832f61..82713ce9 100644
--- a/org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java
+++ b/org.jacoco.core/src/org/jacoco/core/data/ExecFileLoader.java
@@ -12,10 +12,13 @@
package org.jacoco.core.data;
import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
/**
* Convenience utility for loading *.exec files into a
@@ -69,6 +72,41 @@ public class ExecFileLoader {
}
/**
+ * Saves the current content into the given output stream.
+ *
+ * @param stream
+ * stream to save content to
+ * @throws IOException
+ * in case of problems while writing to the stream
+ */
+ public void save(final OutputStream stream) throws IOException {
+ final ExecutionDataWriter dataWriter = new ExecutionDataWriter(stream);
+ sessionInfos.accept(dataWriter);
+ executionData.accept(dataWriter);
+ }
+
+ /**
+ * Saves the current content into the given file.
+ *
+ * @param file
+ * file to save content to
+ * @param append
+ * <code>true</code> if the content should be appended, otherwise
+ * the file is overwritten.
+ * @throws IOException
+ * in case of problems while writing to the stream
+ */
+ public void save(final File file, final boolean append) throws IOException {
+ final OutputStream stream = new BufferedOutputStream(
+ new FileOutputStream(file, append));
+ try {
+ save(stream);
+ } finally {
+ stream.close();
+ }
+ }
+
+ /**
* Returns the session info store with all loaded sessions.
*
* @return session info store