Q: Groovy: Replace in list and make a list for every line I try to replace some ' in a result in my list. But it does not replace this signs.
             linesAsList = lines.toString().split('\t|\r')
             linesAsList.toString().replaceAll(("'"),("")) as List

This is the actually result:
[03.10.2011, '993413376204340783', 13,087, 0400102134, 0060000390]
I was looking for this: [03.10.2011, 993413376204340783, 13,087, 0400102134, 0060000390]
And the next step is, when the programm found more than one result, it should be in a multilist?
Like this:
[[03.10.2011, '993413376204340783', 13,087, 0400102134, 0060000390]
[03.10.2011, '993413376204340783', 13,087, 0400102134, 0060000390]]
Is that realy possible? And how can I do that. After them I'm building a loop for a xml creation.
If You need it, this is the whole code:
import groovy.util.CharsetToolkit;
import java.lang.Object

//Generate pathname
//Pfadname generiert für einfacheres ändern des Speicherortes
def pathname = "C:/mySupport-eclipse/trackandtrace.txt"
//Define Error Status
//Error Status definieren für Weiterverabeitung in mySupport
int errorCode = 0
def errorMessage = ""

def linesAsList = []


def bsknr = "0060000390"
//Define new Fiel
//Neue Datei definieren
def file = new File(pathname)

if(!file.exists())
{
    errorCode = 1
    errorMessage = "File not found"
    out_xml = xmlGenerieren()
}
else
{
    //Read Roews and look for BSK Number, split after tab
    //Zeilen einlesen und nach der BSK Nummer suchen, nach dem Tabulator trennen
    def lines = file.filterLine {
        line -> line ==~ /.*\t${bsknr}\t.*/

        }
    //Split the result after tab and enter, give back as String
    //Das Ergebnis aufteilen bei Tabulator und Enter und zugleich als String zurückgeben

    linesAsList = lines.toString().split('\t|\r')
    linesAsList.toString().replaceAll(("'"),("")) as List
    //Give date, sendnr. and date
    //Liefere nur Datum, Sendungsnummer und Gewicht
    linesAsList = linesAsList[0,1,2,4,5,6]
    xmlGenerieren(linesAsList)
        //println linesAsList
    }

def xmlGenerieren(List linesAsList) {
def writer = new StringWriter()
def builder = new groovy.xml.MarkupBuilder(writer)
linesAsList.pop()


println linesAsList
def listsize = linesAsList.size()


//Test if is empty
//Prüfen ob gültige  Ergebnise gefunden wurden
if (listsize >= 5 || listsize %5)
{
    long i = 0
    long anzEintraege = listsize % 5
    while (i <= anzEintraege)
    {
    builder.result()
    {
        entry(wert:i)
        {
            paketnr(linesAsList[1])
        }
    }
    println writer.toString()
    errorCode = 0
    i++
    }
}
else {

println listsize
//i = listsize / 8
//println i

}

}

Example of input:
Filterkriterien:Frachtfuehrer: POSTCH  Auftraggeber: Testfirma  Zeitraum: 01.10.2011 - 31.10.2011  

ZeitraumVonBis  PaketNr Gewicht Gebühr  Lierf. Nr   KundenNr    AuftragsNr  Name1   Name2   Str Plz Ort Lkz Versandart
03.10.2011  '993413376204340260'    1,000   0,00    0400102100  0052662182      John Doe        Streetname 10   3018    Bern    CH  Priority SI 
03.10.2011  '993413376204340783'    13,087  0,00    0400102134  0060000390      Swisscom Schweiz AG Johnny Doe  Streetname 51   3050    Bern    CH  Priority SI

There are tousands of entries

A: to maybe make Tim's post even more clear... your
linesAsList.toString().replaceAll(("'"),("")) as List

means you will convert the String[], that was stored in linesAsList due to the split before, make a String of it and then you use replace. The result is then a String again, which will be converted to a List. This List will contain for each char in the String on char element. I am pretty sure that was not what you wanted. But it actually doesn't matter all that much, because the result is nowhere assigned. It is simply forgotten then. So after
linesAsList = lines.toString().split('\t|\r')

you need
linesAsList = linesAsList*.replaceAll(("'"),(""))

the result is then a list.
I am adding this more so you can maybe better understand Tim's code, not as alternative solution. Also Tim solved the case with multiple results

A: Right, your code is a bit of a mess, and I'm pretty sure bits of it won't work, but given this tab separated file (that I made up)
03.10.2011  '993413376204340783'    13,087  0400102134  0060000390
04.10.2011  '993413376204341783'    13,087  0400102134  0060000391
05.10.2011  '993413376204342783'    13,087  0400102134  0060000392
06.10.2011  '993413376204340783'    13,087  0400102134  0060000390
07.10.2011  '993413376204343783'    13,087  0400102134  0060000392

This seems to do something like what you wanted:
//Generate pathname
//Pfadname generiert für einfacheres ändern des Speicherortes
String pathname = 'file.txt'

//Define Error Status
//Error Status definieren für Weiterverabeitung in mySupport
int errorCode = 0
String errorMessage = ''

def bsknr = "0060000390"

//Define new Fiel
//Neue Datei definieren
File file = new File(pathname)

if( !file.exists() )
{
  errorCode = 1
  errorMessage = "File not found"
  out_xml = xmlGenerieren()
}
else
{
  //Read Roews and look for BSK Number, split after tab
  //Zeilen einlesen und nach der BSK Nummer suchen, nach dem Tabulator trennen
  String filteredLines = file.filterLine { line ->
    line.split( /\t/ ).grep( bsknr )
  }
  //Split the result after tab and enter, give back as String
  //Das Ergebnis aufteilen bei Tabulator und Enter und zugleich als String zurückgeben
  linesAsList = filteredLines.split( /\n|\r|\n\r|\r\n/ )*.split( /\t/ )*.collect { it.replace( "'", '' ) }

  //Give date, sendnr. and date
  //Liefere nur Datum, Sendungsnummer und Gewicht
  linesAsList = linesAsList*.getAt( [ 0,1,2,4,5,6 ] )
  out_xml =  xmlGenerieren(linesAsList)
}

println out_xml

def xmlGenerieren(List linesAsList) {
  println linesAsList
  new StringWriter().with { writer ->
    new groovy.xml.MarkupBuilder(writer).with { mb ->
      result {
        linesAsList.eachWithIndex { line, index ->
          mb.entry( wert:index ) {
            mb.paketnr( line[ 1 ] )
          }
        }
      }
    }
    writer.toString()
  }
}

