title: Eclipse Split string in lines and remove leading and trailing spaces
body: <p>I am trying to remove spaces from a string where string is divided in lines. After splitting into lines, leading and trailing spaces need to be removed. Where numbers of lines are not fixed.</p>
  
  <p>What I am trying is</p>
  
  <pre><code>      String[] lines = Imgdata.split("\r\n|\r\n");
  
        String firstLine = lines[0].trim();
        String firstLine = lines[1].trim();
  </code></pre>
  
  <p>Here i am able to do for two lines. What can be done where number of lines are not fixed. It can be 4 or 5 or 6.</p>