Bonjour,

Voila j'ai un petit code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
import java.io.*;
 
class TestExec
{
    public static void main(String[] args)
    {
	try
	    {
		String cmd [] = new String [4];
		cmd[0] = "cp";
		cmd[1] = "-rf";
		cmd[2] = "toto/*";
		cmd[3] = "tata";
 
		String temp = "";
		for (int i = 0 ; i < 4 ; i++)
		    {
			temp += cmd[i] + " " ;
		    }
 
		System.out.println("cmd = " + temp);
 
		Runtime rt = Runtime.getRuntime();
		Process proc = rt.exec(cmd, null, new File("/home/vincent/"));
 
		// Mise en attente tant que le process n'est pas termine.
		int exitVal = proc.waitFor() ;
		if (exitVal != 0)
		    { // Si la simulation s'est mal deroule, alors on fait remonter l'exception et on quitte
			throw new Exception ("\n \n Exit Process : " + exitVal + "... \n \n") ;
		    }
		}
	catch (IOException ioex)
	    {
		System.out.println (ioex.getMessage ()) ;
		ioex.printStackTrace () ;
		System.exit(1) ;
	    }
	catch (Exception ex)
	    {
		System.out.println (ex.getMessage ()) ;
		ex.printStackTrace () ;
		System.exit(1) ;
	    }
 
    }
}
Ce code renvoie 1 en exitVal (waitProc()).
Je ne comprends pas du tout pourquoi.

Si j'enleve '*' et que je fais une copie de "toto" dans "tata", ca marche.
Par contre, ce qui m'interesse, c'est de copier tout ce qu'il y a dans "toto" dans "tata"...

Quelqu'un aurait une idee?

Merci!!!