title: Is there a left()-function for Java strings?
body: <p>I have an string str of unknown length (but not null) and a given maximum length len, this has to fit in. All I want to do, is to cut the string at len.</p>
  
  <p>I know that I can use </p>
  
  <pre><code>str.substring(0, Math.min(len, str.length()));
  </code></pre>
  
  <p>but this does not come handy, if I try to write stacked code like this</p>
  
  <pre><code>code = str.replace(" ", "").left(len)
  </code></pre>
  
  <p>I know that I can write my own function but I would prefer an existing solution. Is there an existing left()-function in Java?</p>