Commit 36f04277 authored by Matthias Betz's avatar Matthias Betz
Browse files

change copy algorithm

parent fcd48bc1
Pipeline #8506 failed with stage
in 28 seconds
......@@ -18,16 +18,38 @@
*/
package de.hft.stuttgart.citydoctor2.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class Copy {
private Copy() {
}
public static <T extends Copyable> T copy(T original) {
CopyHandler handler = new CopyHandler();
return handler.copy(original);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(original);
oos.flush();
oos.close();
byte[] byteArray = out.toByteArray();
ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(in);
return (T) ois.readObject();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
throw new IllegalStateException();
// CopyHandler handler = new CopyHandler();
// return handler.copy(original);
}
}
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