You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-dev@jakarta.apache.org by df...@locus.apache.org on 2000/09/15 07:14:31 UTC

cvs commit: jakarta-oro/src/java/examples splitExample.java

dfs         00/09/14 22:14:31

  Modified:    src/java/examples splitExample.java
  Log:
  Updated example to use new split method.
  
  Revision  Changes    Path
  1.3       +10 -6     jakarta-oro/src/java/examples/splitExample.java
  
  Index: splitExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/examples/splitExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- splitExample.java	2000/07/23 23:25:11	1.2
  +++ splitExample.java	2000/09/15 05:14:30	1.3
  @@ -61,7 +61,7 @@
    * This is a test program demonstrating the use of the Util.split() method.
    *
    @author <a href="mailto:dfs@savarese.org">Daniel F. Savarese</a>
  - @version $Id: splitExample.java,v 1.2 2000/07/23 23:25:11 jon Exp $
  + @version $Id: splitExample.java,v 1.3 2000/09/15 05:14:30 dfs Exp $
    */
   public final class splitExample {
   
  @@ -85,10 +85,11 @@
     public static final void main(String args[]) {
       int limit, i;
       String regularExpression, input;
  -    Vector results;
  +    List results = new ArrayList();
       Pattern pattern = null;
       PatternMatcher matcher;
       PatternCompiler compiler;
  +    Iterator elements;
   
       // Make sure there are sufficient arguments
       if(args.length < 2) {
  @@ -121,9 +122,12 @@
   
       // Split the input and print the resulting list.
       System.out.println("split results: ");
  -    results = Util.split(matcher, pattern, input, limit);
  -    for(i = 0; i < results.size(); i++){
  -      System.out.println("item " + i + ": " + (String)results.elementAt(i));
  -    }
  +    Util.split(results, matcher, pattern, input, limit);
  +    elements = results.iterator();
  +
  +    i = 0;
  +    while(elements.hasNext())
  +      System.out.println("item " + i++ + ": " + (String)elements.next());
  +
     }
   }