code: public static <T extends State> void deserializeStateFromInputStream(InputStream is, T state) throws IOException {
      try (DataInputStream dis = (new DataInputStream(is))) {
        state.readFields(dis);
      }
    }
docs: Deserialize/read a {@link State} instance from a file.
  
  @param is {@link InputStream} containing the state.
  @param state an empty {@link State} instance to deserialize into
  @param <T> the {@link State} object type
  @throws IOException if it fails to deserialize the {@link State} instance