Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
36f04277
Commit
36f04277
authored
1 year ago
by
Matthias Betz
Browse files
Options
Download
Email Patches
Plain Diff
change copy algorithm
parent
fcd48bc1
No related merge requests found
Pipeline
#8506
failed with stage
in 28 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/Copy.java
+27
-5
...rc/main/java/de/hft/stuttgart/citydoctor2/utils/Copy.java
with
27 additions
and
5 deletions
+27
-5
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/Copy.java
+
27
-
5
View file @
36f04277
...
@@ -18,16 +18,38 @@
...
@@ -18,16 +18,38 @@
*/
*/
package
de.hft.stuttgart.citydoctor2.utils
;
package
de.hft.stuttgart.citydoctor2.utils
;
public
class
Copy
{
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
()
{
private
Copy
()
{
}
}
public
static
<
T
extends
Copyable
>
T
copy
(
T
original
)
{
public
static
<
T
extends
Copyable
>
T
copy
(
T
original
)
{
CopyHandler
handler
=
new
CopyHandler
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
return
handler
.
copy
(
original
);
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);
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets