A voir également:
- Arguments pour la fonction .Runtime ()
- Fonction si et - Guide
- Directx runtime - Télécharger - Pilotes & Matériel
- Visual c++ runtime - Guide
- Java runtime environment - Télécharger - Langages
- Fonction miroir - Guide
1 réponse
Normalement, ton code devrait fonctionner et les espaces n'ont aucune incidence sur l'ordre des arguments, seuls la case du tableau indique l'ordre de l'élément.
Voici un exemple d'un programme "Test" qui s'appelle lui même :
Voici un exemple d'exécution :
Voici un exemple d'un programme "Test" qui s'appelle lui même :
import java.io.IOException; import java.util.Scanner; public class Test { public static void main(String[] args) throws IOException, InterruptedException { if (args.length==0) { Process p = Runtime.getRuntime().exec(new String[] {"java", "Test", "arg1", "arg2 arg3"}); System.out.println(p.waitFor()); Scanner out = new Scanner(p.getInputStream()); while (out.hasNextLine()) System.out.println(out.nextLine()); out.close(); Scanner err = new Scanner(p.getErrorStream()); while (err.hasNextLine()) System.out.println(err.nextLine()); err.close(); } else { for (String arg : args) System.out.println(arg); } } }
Voici un exemple d'exécution :
$ java Test a b a b $ java Test 0 arg1 arg2 arg3