title: Reading from a text file as an arraylist/hashmap
body: <p>Okay so here's an explanation of what I have to write:  </p>
  
  <ul>
  <li><code>getBreadInfo</code> - reads bread.txt into an array list (containing bread
  name, $, and price) and then assigns to an array breadInfo[], then
  return this array for SandwichApp to display bread menu.</li>
  <li><code>getBread</code> - is similar to getBreadInfo, except it only contains the
  bread name, and return another array bread[] for SandwichApp to figure
  out which bread the user selected because user type in a number
  associate with the bread (index+1), rather than bread name.</li>
  <li><code>getMapBreadPrice</code> - is similar to the above two, except it returns a
  hash map containing pair values for bread name (key) and price (value)
  for SandwichApp to figure out what is the price for the bread user
  selected.</li>
  </ul>
  
  <p>This is what I have written.  Just wondering if this is correct or not? </p>
  
  <pre><code>public class SandwichDB {  
  private ArrayList&lt;String&gt; breadsList = null;
  
  public String[] getBreadInfo()
  { 
      breadsList = new ArrayList&lt;&gt;();
  
          try (BufferedReader in =
                  new BufferedReader(
                  new FileReader("bread.txt")))
          {
              String line = in.readLine();
              while (line != null)
              {
                  String[] elems = line.split("~");
                  breadsList.add(elems[0]+ " $" + elems[1]);  
              }
  
          }
          catch(IOException e)
          {
              System.out.println(e);
              return null;
          }
      String[] breadInfo = breadsList.toArray(new String[]{});
      return breadInfo;
  }
  public String[] getBread()
  {
      breadsList = new ArrayList&lt;&gt;();
  
          try (BufferedReader in =
                  new BufferedReader(
                  new FileReader("bread.txt")))
          {
              String line = in.readLine();
              while (line != null)
              {
                  String[] elems = line.split("~");
                  breadsList.add(elems[0]);  
              }
  
          }
          catch(IOException e)
          {
              System.out.println(e);
              return null;
          }
          String[] bread = breadsList.toArray(new String[]{});
          return bread;
  }
  public HashMap&lt;String, String&gt; getMapBreadPrice()
          {
              HashMap&lt;String, String&gt; mapBreadPrice = new HashMap&lt;&gt;();
              String line, elems[];
              try
              {
                  FileReader fr = new FileReader("bread.txt");
                  BufferedReader br = new BufferedReader(fr);
  
                  while ((line=br.readLine()) != null)
                  {
                      elems = line.split("~");
                      mapBreadPrice.put(elems[0], elems[1]);
                  }
              }
              catch(IOException e)
              {
                  System.out.println(e);
                  return null;
              }
              return mapBreadPrice;
          }
          }
  </code></pre>