diff --git a/src/main/java/envoy/util/SerializationUtils.java b/src/main/java/envoy/util/SerializationUtils.java index 68bd098..558429c 100644 --- a/src/main/java/envoy/util/SerializationUtils.java +++ b/src/main/java/envoy/util/SerializationUtils.java @@ -3,6 +3,8 @@ package envoy.util; import java.io.*; /** + * Defines utility methods related to serialization. + *
* Project: envoy-client
* File: SerializationUtils.java
* Created: 23.12.2019
@@ -92,22 +94,23 @@ public class SerializationUtils {
}
/**
- * Serializes an arbitrary object to a file.
+ * Serializes arbitrary objects to a file.
*
* @param file the file to serialize to
- * @param obj the object to serialize
+ * @param objs the objects to serialize
* @throws IOException if an error occurred during serialization
* @since Envoy Common v0.2-alpha
*/
- public static void write(File file, Object obj) throws IOException {
+ public static void write(File file, Object... objs) throws IOException {
if (file == null) throw new NullPointerException("File is null");
- if (obj == null) throw new NullPointerException("Object to serialize is null");
+ if (objs == null) throw new NullPointerException("Null array passed to serialize");
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file))) {
- out.writeObject(obj);
+ for (var obj : objs)
+ out.writeObject(obj);
}
}