title: Scala: Draw table to console
body: <p>I need to display a table in a console.</p>
  
  <p>My simple solution, if you would call it a "solution", is as follows:</p>
  
  <pre><code>  override def toString() = {
      var res = "\n"
        var counter = 1;
        res += stateDb._1 + "\n"
        res += "  +----------------------------+\n"
        res += "  +     State Table            +\n"
        res += "  +----------------------------+\n"
        for (entry &lt;- stateDb._2) {
          res += "  | " + counter + "\t | " + entry._1 + " | " + entry._2 + " |\n"
          counter += 1;
        }
        res += "  +----------------------------+\n"
        res += "\n"
      res
  
    }
  </code></pre>
  
  <p>We don't have to argue this</p>
  
  <ul>
  <li>a is looking bad when displayed</li>
  <li>b code looks kinda messed up</li>
  </ul>
  
  <p>Actually, such a question was asked for C# but I would like to know a nice solution for Scala as well.</p>
  
  <p>So what is a (nice/good/simple/whatever) way to draw such a table in Scala to the console?</p>
  
  <pre><code>-------------------------------------------------------------------------
  |    Column 1     |    Column 2     |    Column 3     |    Column 4     |
  -------------------------------------------------------------------------
  |                 |                 |                 |                 |
  |                 |                 |                 |                 |
  |                 |                 |                 |                 |
  -------------------------------------------------------------------------
  </code></pre>