Index: IOUtils.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/util/IOUtils.java,v
retrieving revision 1.8
diff -u -r1.8 IOUtils.java
--- IOUtils.java	2001/08/20 13:55:18	1.8
+++ IOUtils.java	2001/08/28 22:23:40
@@ -9,6 +9,8 @@
 
 import org.apache.log.Hierarchy;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -301,5 +303,30 @@
     File parent = file.getParentFile();
     if (parent != null) parent.mkdirs();
     return file;
+  }
+
+  /**
+   * Returns a byte array from the given object.
+   *
+   * @param object to convert
+   * @return byte array from the object
+   */
+  public static byte[] objectToBytes(Object object) throws IOException {
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ObjectOutputStream os = new ObjectOutputStream(baos);
+    os.writeObject(object);
+    return baos.toByteArray();
+  }
+
+  /**
+   * Returns a object from the given byte array.
+   *
+   * @param byte array to convert
+   * @return object
+   */
+  public static Object bytesToObject(byte[] bytes) throws IOException, ClassNotFoundException {
+    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+    ObjectInputStream is = new ObjectInputStream(bais);
+    return is.readObject();
   }
 }

