Pattern spacePat = Pattern.compile ("\\s+"); String [] tokens = spacePat.split (argv [0]); for (int i = 0; i < tokens.length; i++) { System.out.println ("" + i + ": " + tokens [i]); }