@Override
 public void write(OutputStream outputStream) throws IOException {
   outputStream.write(12); // 对象类型
   byte[] strBytes = value.getBytes();
   outputStream.write(ByteUtils.intToByte(strBytes.length));
   outputStream.write(strBytes);
 }
 @Override
 public void read(InputStream inputStream) throws IOException {
   byte[] strLengthBytes = new byte[4];
   inputStream.read(strLengthBytes);
   int strLength = ByteUtils.byteToInt(strLengthBytes);
   byte[] strBytes = new byte[strLength];
   inputStream.read(strBytes);
   value = new String(strBytes);
 }
Exemplo n.º 3
0
 @Override
 public void write(OutputStream outputStream) throws IOException {
   outputStream.write(0); // 对象类型
   outputStream.write(ByteUtils.doubleToByte(value));
 }
Exemplo n.º 4
0
 @Override
 public void read(InputStream inputStream) throws IOException {
   byte[] buffer = new byte[8];
   inputStream.read(buffer);
   value = ByteUtils.byteToDouble(buffer);
 }