@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); }
@Override public void write(OutputStream outputStream) throws IOException { outputStream.write(0); // 对象类型 outputStream.write(ByteUtils.doubleToByte(value)); }
@Override public void read(InputStream inputStream) throws IOException { byte[] buffer = new byte[8]; inputStream.read(buffer); value = ByteUtils.byteToDouble(buffer); }