code: public static FSA read(InputStream stream) throws IOException {
      final FSAHeader header = FSAHeader.read(stream);
  
      switch (header.version) {
        case FSA5.VERSION:
          return new FSA5(stream);
        case CFSA.VERSION:
          return new CFSA(stream);
        case CFSA2.VERSION:
          return new CFSA2(stream);
        default:
          throw new IOException(
              String.format(Locale.ROOT, "Unsupported automaton version: 0x%02x", header.version & 0xFF));
      }
    }
docs: A factory for reading automata in any of the supported versions.
  
  @param stream
  The input stream to read automaton data from. The stream is not
  closed.
  @return Returns an instantiated automaton. Never null.
  @throws IOException
  If the input stream does not represent an automaton or is
  otherwise invalid.