|
1 | 1 | package net.sharksystem.asap.utils; |
2 | 2 |
|
3 | | -import net.sharksystem.asap.ASAPHopImpl; |
4 | | -import net.sharksystem.asap.ASAPException; |
5 | | -import net.sharksystem.asap.ASAPHop; |
6 | | -import net.sharksystem.asap.EncounterConnectionType; |
| 3 | +import net.sharksystem.asap.*; |
7 | 4 | import net.sharksystem.utils.Log; |
8 | 5 |
|
9 | 6 | import java.io.*; |
@@ -41,6 +38,30 @@ public static byte[] readByteArray(InputStream is) throws IOException, ASAPExcep |
41 | 38 | return messageBytes; |
42 | 39 | } |
43 | 40 |
|
| 41 | + public static void writeByteArray(byte[][] bytes2Dim, OutputStream os) throws IOException { |
| 42 | + if(bytes2Dim == null) { |
| 43 | + writeNonNegativeIntegerParameter(0, os); |
| 44 | + } else { |
| 45 | + writeNonNegativeIntegerParameter(bytes2Dim.length, os); |
| 46 | + for(int i = 0; i < bytes2Dim.length; i++) { |
| 47 | + ASAPSerialization.writeByteArray(bytes2Dim[i], os); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + public static byte[][] readByte2DimArray(InputStream is) throws IOException, ASAPException { |
| 53 | + // read len |
| 54 | + int len = readIntegerParameter(is); |
| 55 | + if(len == 0) return new byte[0][]; |
| 56 | + |
| 57 | + byte[][] messageBytes = new byte[len][]; |
| 58 | + for(int i = 0; i < len; i++) { |
| 59 | + messageBytes[i] = ASAPSerialization.readByteArray(is); |
| 60 | + } |
| 61 | + |
| 62 | + return messageBytes; |
| 63 | + } |
| 64 | + |
44 | 65 | public static void writeCharSequenceParameter(CharSequence parameter, OutputStream os) throws IOException { |
45 | 66 | if(parameter == null || parameter.length() < 1) return; |
46 | 67 | byte[] bytes = parameter.toString().getBytes(); |
|
0 commit comments