title: Limiting the number of characters in a string, and chopping off the rest
body: <p>I need to create a summary table at the end of a log with some values that 
  are obtained inside a class. The table needs to be printed in fixed-width 
  format. I have the code to do this already, but I need to limit Strings, 
  doubles and ints to a fixed-width size that is hard-coded in the code.</p>
  
  <p>So, suppose I want to print a fixed-width table with</p>
  
  <pre><code>    int,string,double,string
      int,string,double,string
      int,string,double,string
      int,string,double,string
  
      and the fixed widths are: 4, 5, 6, 6.
  </code></pre>
  
  <p>If a value exceeds this width, the last characters need to be cut off. So 
  for example:</p>
  
  <pre><code>    124891, difference, 22.348, montreal
  </code></pre>
  
  <p>the strings that need to be printed ought to be:</p>
  
  <pre><code>    1248 diffe 22.348 montre
  </code></pre>
  
  <p>I am thinking I need to do something in the constructor that forces a 
  string not to exceed a certain number of characters. I will probably 
  cast the doubles and ints to a string, so I can enforce the maximum width 
  requirements.</p>
  
  <p>I don't know which method does this or if a string can be instantiated to 
  behave taht way.  Using the formatter only helps with the 
  fixed-with formatting for printing the string, but it does not actually 
  chop characters that exceed the maximum length.</p>