title: How to parse Cucumber feature file in java or groovy?
body: <p>I need to parse .feature files and produce Json data. I am currently able to read the steps using regular expressions, But i want to parse entire feature file.</p>
  
  <pre><code>Path path= Paths.get("path to feature file").toAbsolutePath();
      try {
          File file = new File(path.toString())
                      try {
                          List&lt;String&gt; data = Files.readAllLines(file);
  
                          data.forEach(line -&gt; {
                              Matcher stepMatcher = Pattern.compile("\\b(Given|When|Then|And|But)(.*)").matcher(line);
                              if (stepMatcher.find()) {
                                  System.out.println(line);
                              }
                          });
                      } catch (Exception e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
  </code></pre>