< prev index next >

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

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


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




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


< prev index next >