title: Writing to text file with automatic spacing
body: <p>I'm printing out a table format to a text file using Java. I have three columns and three rows. The trick is to get the columns to line up. What's a method of finding the spacing between them? The code below doesn't work because it sets a set spacing between the columns</p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.ArrayList;
  
  public class makeTable {
  
  static ArrayList&lt;String&gt; name = new ArrayList&lt;String&gt;();
  static ArrayList&lt;String&gt; model = new ArrayList&lt;String&gt;();
  static ArrayList&lt;String&gt; year = new ArrayList&lt;String&gt;();
  
  public static void main(String arg[]) {
      addData();
      BufferedWriter writeTable = null;
      try {
          writeTable = new BufferedWriter(new FileWriter("/home/oveledar/Desktop/table.txt"));
          for (int i = 0; i &lt; name.size(); i++){
              writeTable.write(name.get(i) + "   " + model.get(i) +  "   " + year.get(i));
              writeTable.newLine();
          }
      } catch (IOException e) {
          System.err.println(e);
      } finally {
          if (writeTable != null) {
              try {
                  writeTable.close();
              } catch (IOException e) {
                  System.err.println(e);
              }
          }
      }
  }
  
  public static void addData(){
      name.add("Dodge");
      name.add("BMW");
      name.add("VW");
      model.add("Caravan");
      model.add("323i");
      model.add("Passat");
      year.add("2006");
      year.add("2009");
      year.add("2011");
  
  }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Dodge   Caravan   2006
  BMW   323i   2009
  VW   Passat   2011
  </code></pre>
  
  <p>"/t" doesn't work for long names</p>
  
  <pre><code> Dodge  Caravan 2006
   BMW    323i    2009
   VW     Long model name here    2011
  </code></pre>