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

    Map<Integer, Integer> stateMap = new HashMap<>();

    try (BufferedReader in = Files.newBufferedReader(
      textPath, StandardCharsets.UTF_8)) {

      // first line contains the initial state
      int initialState = Integer.parseInt(in.readLine());
      stateMap.put(initialState, getNewState(initialState, stateMap));
      this.setInitialState(getNewState(initialState, stateMap));

      String line;
      while (true) {
        // read edges
        line = in.readLine();
        String[] edgeParts = line.split(" ");
        if (edgeParts.length != 3) {
          // all edges have been read
          break;
        }
        int startState = Integer.parseInt(edgeParts[0]);
        int endState = Integer.parseInt(edgeParts[1]);
        String label = edgeParts[2];
        if (label.equals("EPSILON")) {
          label = null;
        }
        this.newEdge(
          label,
          getNewState(startState, stateMap),
          getNewState(endState, stateMap));
      }

      // read final states;
      // line already contains the first final state
      this.setFinalState(getNewState(Integer.parseInt(line), stateMap));
      while ((line = in.readLine()) != null) {
        this.setFinalState(getNewState(Integer.parseInt(line), stateMap));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
/**
   * Initializes this automaton from text based format at the given path.
   *
   * @param textPath
   *          the path from where to read the text
   */
Initializes this automaton from text based format at the given path.

@param textPath
the path from where to read the text
Initializes this automaton from text based format at the given path . @param textPath the path from where to read the text
public void readFromText(Path textPath) {
    Map<Integer, Integer> stateMap = new HashMap<>();
    try (BufferedReader in = Files.newBufferedReader(
      textPath, StandardCharsets.UTF_8)) {
      int initialState = Integer.parseInt(in.readLine());
      stateMap.put(initialState, getNewState(initialState, stateMap));
      this.setInitialState(getNewState(initialState, stateMap));
      String line;
      while (true) {
        line = in.readLine();
        String[] edgeParts = line.split(" ");
        if (edgeParts.length != 3) {
          break;
        }
        int startState = Integer.parseInt(edgeParts[0]);
        int endState = Integer.parseInt(edgeParts[1]);
        String label = edgeParts[2];
        if (label.equals("EPSILON")) {
          label = null;
        }
        this.newEdge(
          label,
          getNewState(startState, stateMap),
          getNewState(endState, stateMap));
      }
      this.setFinalState(getNewState(Integer.parseInt(line), stateMap));
      while ((line = in.readLine()) != null) {
        this.setFinalState(getNewState(Integer.parseInt(line), stateMap));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
public void readFromText ( Path textPath ) { Map < Integer , Integer > stateMap = new HashMap < > ( ) ; try ( BufferedReader in = Files . newBufferedReader ( textPath , StandardCharsets . UTF_8 ) ) { int initialState = Integer . parseInt ( in . readLine ( ) ) ; stateMap . put ( initialState , getNewState ( initialState , stateMap ) ) ; this . setInitialState ( getNewState ( initialState , stateMap ) ) ; String line ; while ( true ) { line = in . readLine ( ) ; String [ ] edgeParts = line . split ( " " ) ; if ( edgeParts . length != 3 ) { break ; } int startState = Integer . parseInt ( edgeParts [ 0 ] ) ; int endState = Integer . parseInt ( edgeParts [ 1 ] ) ; String label = edgeParts [ 2 ] ; if ( label . equals ( "EPSILON" ) ) { label = null ; } this . newEdge ( label , getNewState ( startState , stateMap ) , getNewState ( endState , stateMap ) ) ; } this . setFinalState ( getNewState ( Integer . parseInt ( line ) , stateMap ) ) ; while ( ( line = in . readLine ( ) ) != null ) { this . setFinalState ( getNewState ( Integer . parseInt ( line ) , stateMap ) ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Initializes this automaton from text based format at the given path.
Initializes this automaton from text based format at the given path .
// first line contains the initial state
 // read edges
 // all edges have been read
 // read final states;
 // line already contains the first final state
