title: Remove end of line characters from end of Java String
body: <p>I have a string which I'd like to remove the end of line characters from the very end of the string only using Java</p>
  
  <pre><code>"foo\r\nbar\r\nhello\r\nworld\r\n"
  </code></pre>
  
  <p>which I'd like to become</p>
  
  <pre><code>"foo\r\nbar\r\nhello\r\nworld"
  </code></pre>
  
  <p>(This question is similar to, but not the same as question <a href="https://stackoverflow.com/questions/593671">593671</a>)</p>