File tree 1 file changed +6
-9
lines changed
Chapter06/P132_ObjectToStringSer/src/main/java/modern/challenge
1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,14 @@ private Converters() {
14
14
throw new AssertionError ("Cannot be instantiated" );
15
15
}
16
16
17
- public static String objectToString (Serializable obj ) throws IOException {
18
-
19
- ByteArrayOutputStream baos = new ByteArrayOutputStream ();
17
+ public static String objectToString (Serializable obj ) throws IOException {
20
18
21
- try ( ObjectOutputStream ois = new ObjectOutputStream (baos )) {
19
+ try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ();
20
+ ObjectOutputStream ois = new ObjectOutputStream (baos )) {
22
21
ois .writeObject (obj );
23
- }
24
-
25
- baos .close ();
26
-
27
- return Base64 .getEncoder ().encodeToString (baos .toByteArray ());
22
+
23
+ return Base64 .getEncoder ().encodeToString (baos .toByteArray ());
24
+ }
28
25
}
29
26
30
27
public static Object stringToObject (String obj )
You can’t perform that action at this time.
0 commit comments