< prev index next >

src/java.base/share/classes/java/lang/Runtime.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


 388      * @throws  SecurityException
 389      *          If a security manager exists and its
 390      *          {@link SecurityManager#checkExec checkExec}
 391      *          method doesn't allow creation of the subprocess
 392      *
 393      * @throws  IOException
 394      *          If an I/O error occurs
 395      *
 396      * @throws  NullPointerException
 397      *          If {@code command} is {@code null},
 398      *          or one of the elements of {@code envp} is {@code null}
 399      *
 400      * @throws  IllegalArgumentException
 401      *          If {@code command} is empty
 402      *
 403      * @see     ProcessBuilder
 404      * @since 1.3
 405      */
 406     public Process exec(String command, String[] envp, File dir)
 407         throws IOException {
 408         if (command.length() == 0)
 409             throw new IllegalArgumentException("Empty command");
 410 
 411         StringTokenizer st = new StringTokenizer(command);
 412         String[] cmdarray = new String[st.countTokens()];
 413         for (int i = 0; st.hasMoreTokens(); i++)
 414             cmdarray[i] = st.nextToken();
 415         return exec(cmdarray, envp, dir);
 416     }
 417 
 418     /**
 419      * Executes the specified command and arguments in a separate process.
 420      *
 421      * <p>This is a convenience method.  An invocation of the form
 422      * {@code exec(cmdarray)}
 423      * behaves in exactly the same way as the invocation
 424      * {@link #exec(String[], String[], File) exec}{@code (cmdarray, null, null)}.
 425      *
 426      * @param   cmdarray  array containing the command to call and
 427      *                    its arguments.
 428      *




 388      * @throws  SecurityException
 389      *          If a security manager exists and its
 390      *          {@link SecurityManager#checkExec checkExec}
 391      *          method doesn't allow creation of the subprocess
 392      *
 393      * @throws  IOException
 394      *          If an I/O error occurs
 395      *
 396      * @throws  NullPointerException
 397      *          If {@code command} is {@code null},
 398      *          or one of the elements of {@code envp} is {@code null}
 399      *
 400      * @throws  IllegalArgumentException
 401      *          If {@code command} is empty
 402      *
 403      * @see     ProcessBuilder
 404      * @since 1.3
 405      */
 406     public Process exec(String command, String[] envp, File dir)
 407         throws IOException {
 408         if (command.isEmpty())
 409             throw new IllegalArgumentException("Empty command");
 410 
 411         StringTokenizer st = new StringTokenizer(command);
 412         String[] cmdarray = new String[st.countTokens()];
 413         for (int i = 0; st.hasMoreTokens(); i++)
 414             cmdarray[i] = st.nextToken();
 415         return exec(cmdarray, envp, dir);
 416     }
 417 
 418     /**
 419      * Executes the specified command and arguments in a separate process.
 420      *
 421      * <p>This is a convenience method.  An invocation of the form
 422      * {@code exec(cmdarray)}
 423      * behaves in exactly the same way as the invocation
 424      * {@link #exec(String[], String[], File) exec}{@code (cmdarray, null, null)}.
 425      *
 426      * @param   cmdarray  array containing the command to call and
 427      *                    its arguments.
 428      *


< prev index next >