public List<ReplicaTokenInfo> deserializeTokens(InputStream inputStream, String replicaTokenFilename) throws IOException, ReplicationException {
      CrcInputStream crcStream = new CrcInputStream(inputStream);
      DataInputStream stream = new DataInputStream(crcStream);
      List<ReplicaTokenInfo> tokenInfoList = new ArrayList<>();
      try {
        short version = stream.readShort();
        if (version < VERSION_0 || version > VERSION_1) {
          throw new ReplicationException("Invalid version " + version + " found during replica token deserialization from file " + replicaTokenFilename);
        }
        while (stream.available() > Crc_Size) {
          // read partition id
          PartitionId partitionId = clusterMap.getPartitionIdFromStream(stream);
          // read remote node host name
          String hostname = Utils.readIntString(stream);
          // read remote replica path
          String replicaPath = Utils.readIntString(stream);
          // read remote port
          int port = stream.readInt();
          // read total bytes read from local store
          long totalBytesReadFromLocalStore = stream.readLong();
          //read replica type; prior to VERSION_1 all the replicas were DISK_BACKED only
          ReplicaType replicaType = ReplicaType.DISK_BACKED;
          if (version > VERSION_0) {
            replicaType = ReplicaType.values()[stream.readShort()];
          }
          // read replica token
          FindTokenFactory findTokenFactory = tokenHelper.getFindTokenFactoryFromReplicaType(replicaType);
          FindToken token = findTokenFactory.getFindToken(stream);

          tokenInfoList.add(
              new ReplicaTokenInfo(partitionId, hostname, replicaPath, port, totalBytesReadFromLocalStore, token));
        }

        long computedCrc = crcStream.getValue();
        long readCrc = stream.readLong();
        if (computedCrc != readCrc) {
          throw new ReplicationException(
              "Crc mismatch during replica token deserialization, computed " + computedCrc + ", read " + readCrc);
        }
        return tokenInfoList;
      } catch (IOException e) {
        throw new ReplicationException("IO error deserializing replica tokens from file " + replicaTokenFilename, e);
      } finally {
        stream.close();
      }
    }
Class to serialize and deserialize replica tokens
ambry-replication/src/main/java/com/github/ambry/replication/ReplicaTokenPersistor.java