[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-scm
Subject:    groovy/groovy-core/src/main/org/codehaus/groovy/runtime DefaultGroovyMethods.java
From:       russel () codehaus ! org
Date:       2005-07-29 12:01:33
Message-ID: 20050729120133.23979.qmail () codehaus ! org
[Download RAW message or body]

russel      2005/07/29 08:01:33

  Modified:    groovy-core/src/main/org/codehaus/groovy/runtime
                        DefaultGroovyMethods.java
  Log:

  Added a more groovy version of the list execute and sorted the tests.
  
  Revision  Changes    Path
  1.171     +23 -4     \
groovy/groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java  
  Index: DefaultGroovyMethods.java
  ===================================================================
  RCS file: /home/projects/groovy/scm/groovy/groovy-core/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java,v
  retrieving revision 1.170
  retrieving revision 1.171
  diff -u -r1.170 -r1.171
  --- DefaultGroovyMethods.java	28 Jul 2005 23:50:20 -0000	1.170
  +++ DefaultGroovyMethods.java	29 Jul 2005 12:01:33 -0000	1.171
  @@ -278,7 +278,7 @@
       }
   
     /**
  -   *  Printf to a console.  Only works with JDK1.5 or alter.
  +   *  Printf to a console.  Only works with JDK1.5 or later.
      *
      *  @author Russel Winder
      *  @version 2005.02.01.15.53
  @@ -3236,10 +3236,29 @@
        *
        * @param commandArray an array of <code>String<code> containing the command \
                name and
        * parameters as separate items in the array.
  -     * @return the Process which has just started for this command line string
  +     * @return the Process which has just started for this command line string.
        */
       public static Process execute ( final String[] commandArray ) throws \
IOException {  return Runtime.getRuntime ( ).exec ( commandArray ) ;
  +    }
  +
  +    /**
  +     * Executes the command specified by the <code>String</code> list that is the \
parameter.  +     * The first item in the array is the command the others are the \
parameters. All entries  +     * must be <code>String</code>s.  For more control over \
the process mechanism in JDK 1.5 you  +     * can use \
<code>java.lang.ProcessBuilder</code>.  +     *
  +     * @param commandList a list of <code>String<code> containing the command name \
and  +     * parameters as separate items in the list.
  +     * @return the Process which has just started for this command line string.
  +     */
  +    public static Process execute ( final List commandList ) throws IOException {
  +      final String[] commandArray = new String[commandList.size ( )] ;
  +      Iterator it = commandList.iterator ( ) ;
  +      for ( int i = 0 ; it.hasNext ( ) ; ++i ) {
  +        commandArray[i] = it.next ( ).toString ( ) ;
  +      }
  +      return execute ( commandArray ) ;
       }
   
       /**
  
  
  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic