title: Groovy remove array element
body: <p>i have this gradle task to get zip content and put it into another zip. 
  From src zip, i want to take all in directory 'r' and copy it into the target zip directory 'x/y/z'.<br>
  The code works, but I wonder if it can be more elegant.  </p>
  
  <pre><code>    from( zipTree("a.zip") ) {
          include "r/**"
          includeEmptyDirs = false
          into "x/y/z"
          eachFile { fcd -&gt;
              def segs1 = [fcd.relativePath.segments].flatten().findAll { it2 -&gt; it2 != null };
              segs1.removeAt(3)
              fcd.relativePath = new RelativePath(true, segs1.toArray(new String[0]))
          }
      }
  </code></pre>
  
  <p>The problem I had is that fcd.relativePath.segments is String[], where i want to remove element with index 3.<br>
  Here i convert to list and back to array, brrr.</p>
  
  <p>Ideas?</p>
  
  <p>Frank</p>