title: I want to parse multiple strings into variables from a .txt file in java. What's the easiest way to do it?
body: <p>What's the best way to do it? Should I use the File class and scanner? I've never done it before and can't seem to find a solid guide for it online so I figured I would ask here.</p>
  
  <p>Edit:<br>
  The text file I am parsing is 3 columns, the first three are ID NAME BIRTHDATE then actual data.</p>
  
  <p>Edit (code from <a href="http://pastie.org/1051615" rel="nofollow noreferrer">pastie</a>):</p>
  
  <pre><code>public void readFromFile(File file ) 
  {
      try
      {
          System.out.println("success..");
          s = new Scanner(file);
          BufferedReader input = new BufferedReader(new FileReader(file));
          String jj = null;
          while((jj = input.readLine())!=null)
          {  
              String [] words = jj.split("\\t");
              String name = "";
              String id = "";
              String birthdate ="";
              for (int i = 3; i&lt;words.length; i+=3)
              {
                  id =words[i];
                  name = words[i+1];
                  birthdate=words[i+2];
                  Person p = new Person(id, name, birthdate);
                  peopleMap.put(p.id,p);
                  names.add(p);
                  System.out.println("New entry added to file: "+name+"\\t"+"ID: "
                                      +id+"\\t"+"Birthdate"+birthdate);
              }
          }
      }
  
      catch(IOException e)
      {
      }
  }
  </code></pre>