Commit 49db1a40215af51d4b1dec521b60cf964b34d40c
1 parent
7f32367741
Exists in
master
and in
6 other branches
1
Showing 1 changed file with 5 additions and 3 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/SerializUtils.java
View file @
49db1a4
1 | 1 | package com.lyms.platform.common.utils; |
2 | 2 | |
3 | 3 | import java.io.*; |
4 | +import java.util.Arrays; | |
4 | 5 | |
5 | 6 | /** |
6 | 7 | * 序列化对象成byte数组 |
7 | 8 | |
... | ... | @@ -17,9 +18,10 @@ |
17 | 18 | baos = new ByteArrayOutputStream(); |
18 | 19 | oos = new ObjectOutputStream(baos); |
19 | 20 | oos.writeObject(object); |
20 | - byte[] bytes = baos.toByteArray(); | |
21 | - return bytes; | |
21 | + oos.flush(); | |
22 | + return baos.toByteArray(); | |
22 | 23 | } catch (Exception e) { |
24 | + ExceptionUtils.catchException(e,"objToByte Error. " +object); | |
23 | 25 | } |
24 | 26 | return null; |
25 | 27 | } |
... | ... | @@ -32,7 +34,7 @@ |
32 | 34 | ObjectInputStream ois = new ObjectInputStream(bais); |
33 | 35 | return ois.readObject(); |
34 | 36 | } catch (Exception e) { |
35 | - e.printStackTrace(); | |
37 | + ExceptionUtils.catchException(e, "byteToObj Error. " + Arrays.toString(bytes)); | |
36 | 38 | } |
37 | 39 | return null; |
38 | 40 | } |