title: How to trim a string from carriage returns in java
body: <p>I have a string:</p>
  
  <pre><code>\n\n\n\Mytext is here\n new line \n\n
  </code></pre>
  
  <p>with an unknown amount of \n at the beginning and at the end.</p>
  
  <p>How can I trim this string to </p>
  
  <pre><code>Mytext is here\n new line 
  </code></pre>
  
  <p>in an elegant way?</p>
  
  <p>I know I could code this with my own function. But, perhaps there is a simple solution?</p>