(DataOutput out, String s)
| 59 | } |
| 60 | |
| 61 | public static void writeChararray(DataOutput out, String s) throws IOException { |
| 62 | // a char can take up to 3 bytes in the modified utf8 encoding |
| 63 | // used by DataOutput.writeUTF, so use UNSIGNED_SHORT_MAX/3 |
| 64 | byte[] utfBytes = s.getBytes(BinInterSedes.UTF8); |
| 65 | int length = utfBytes.length; |
| 66 | if (length < BinInterSedes.UNSIGNED_SHORT_MAX) { |
| 67 | out.writeByte(BinInterSedes.SMALLCHARARRAY); |
| 68 | out.writeShort(length); |
| 69 | } else { |
| 70 | out.writeByte(BinInterSedes.CHARARRAY); |
| 71 | out.writeInt(length); |
| 72 | } |
| 73 | out.write(utfBytes); |
| 74 | } |
| 75 | |
| 76 | public static String readChararray(DataInput in, byte type) throws IOException { |
| 77 | int size; |
no test coverage detected