// // Example of using StringTokenizer. // // Usage: // java ParsePath searchpath // where searchpath is a sequence of pathnames separated by ":" // // Description: // Separates components of pathname and prints, one per line. // // Example of use: // java ParsePath /usr/bin:/bin:/usr/local:. // import java.util.StringTokenizer; public class ParsePath { public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: ParsePath " + "[ list of pathnames separated by colons ]"); System.exit(-1); } StringTokenizer st = new StringTokenizer(args[0], ":"); while (st.hasMoreTokens()) { System.out.println(st.nextToken()); } } }