src/main/java/de/dfki/lt/loot/fsa/StringFsa.java
public void saveAsText(Path textPath) {

    try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(
      textPath, StandardCharsets.UTF_8))) {

      List<Integer> collectedFinalStates = new ArrayList<>();

      // write initial state
      out.println(this.getInitialState());

      // for each state, write its outgoing edges
      for (int vertex : this) {
        for (Edge<String> oneEdge : this.getOutEdges(vertex)) {
          String edgeInfo = oneEdge.getInfo();
          if (null == edgeInfo) {
            edgeInfo = "EPSILON";
          }
          out.println(
            String.format("%d %d %s",
              oneEdge.getSource(),
              oneEdge.getTarget(),
              edgeInfo));
        }
        if (this.isFinalState(vertex)) {
          collectedFinalStates.add(vertex);
        }
      }

      // write final states
      for (int oneFinalState : collectedFinalStates) {
        out.println(oneFinalState);
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
/**
   * Save this automaton in a text based format at the given path.
   *
   * @param textPath
   *          the path where to write the text to
   */
Save this automaton in a text based format at the given path.

@param textPath
the path where to write the text to
Save this automaton in a text based format at the given path . @param textPath the path where to write the text to
public void saveAsText(Path textPath) {
    try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(
      textPath, StandardCharsets.UTF_8))) {
      List<Integer> collectedFinalStates = new ArrayList<>();
      out.println(this.getInitialState());
      for (int vertex : this) {
        for (Edge<String> oneEdge : this.getOutEdges(vertex)) {
          String edgeInfo = oneEdge.getInfo();
          if (null == edgeInfo) {
            edgeInfo = "EPSILON";
          }
          out.println(
            String.format("%d %d %s",
              oneEdge.getSource(),
              oneEdge.getTarget(),
              edgeInfo));
        }
        if (this.isFinalState(vertex)) {
          collectedFinalStates.add(vertex);
        }
      }
      for (int oneFinalState : collectedFinalStates) {
        out.println(oneFinalState);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
public void saveAsText ( Path textPath ) { try ( PrintWriter out = new PrintWriter ( Files . newBufferedWriter ( textPath , StandardCharsets . UTF_8 ) ) ) { List < Integer > collectedFinalStates = new ArrayList < > ( ) ; out . println ( this . getInitialState ( ) ) ; for ( int vertex : this ) { for ( Edge < String > oneEdge : this . getOutEdges ( vertex ) ) { String edgeInfo = oneEdge . getInfo ( ) ; if ( null == edgeInfo ) { edgeInfo = "EPSILON" ; } out . println ( String . format ( "%d %d %s" , oneEdge . getSource ( ) , oneEdge . getTarget ( ) , edgeInfo ) ) ; } if ( this . isFinalState ( vertex ) ) { collectedFinalStates . add ( vertex ) ; } } for ( int oneFinalState : collectedFinalStates ) { out . println ( oneFinalState ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Save this automaton in a text based format at the given path.
Save this automaton in a text based format at the given path .
// write initial state
 // for each state, write its outgoing edges
 // write final states
