With special case I was referring to the startsWith/endsWith checks. If you trim, the code could be something like this if I'm not mistaken:

    String[] csvTileIds = csvText.trim().split(",[\\s]*");