String zeile = "eins -zwei -drei vier";StringTokenizer ST = new StringTokenizer(zeile,"-");int anzahl = ST.countTokens();for(int i = 0; i < anzahl; i++){ String token = ST.nextToken(); if(i == 0 || i == 2) { if( i == 0) token = token + "sonstwas"; else token = " -" + token; System.out.print(token); }}