title: How can I format the different sections of the input .txt in Java
body: <p>I need to format the I/O text, which comes from a .txt file. I am able to print it, but I can't separate it in the different categories. </p>
  
  <pre><code>public class Main {
      public static void main(String[] args) throws Exception {
  
      class Recipe implements java.io.Serializable {
          private String name, ingredients, steps;
  
  
          public Recipe(String name, String ingredients, String steps) {
              this.name = name;
              this.ingredients = ingredients;
              this.steps = steps;
           }
  
          public String toString(){
               return "dishName: " + name + " ingredients: " + ingredients + " steps: ";
           }
  
      }
  
          Scanner input = null;
  
          try {
              //Choose the file that you will use. 
              input = new Scanner (new BufferedReader(new FileReader ("Root/src/recipes.txt")));
  
              while ( input.hasNext() ) {
  
                  System.out.println(input.nextLine());
  
              }
  
              //Read your input and create the Objects Recipe
  
  
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              try {
                  if (input != null){
                      input.close();
                  }
              } finally {
                  if (input != null){
                      input.close();
                  }
              }
          }
      }
  }
  </code></pre>