passer un parametre de Type Array avec Runtime.exec
Bonjour a tous.
S'il vous plait j'ai un soucis et je ne sais pas est ce que c'est possible ou pas!!je veux passer un paramètre de type ArrayList<String>en java.j'ai essayé même de convertir la liste en une chaîne de caractères mais ça ne fonctionne pas.voici mon code :
Code:
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 49 50 51 52 53 54 55 56 57 58 59 60
| JButton b1= new JButton("Commit");
b1.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
Process shell = null;
try {
XMLParser xp2 = new XMLParser() ;
NodeList lista2;
lista2=xp2.RecupererParam(e.getActionCommand());
List<String> urls2 = new ArrayList<String>();
for (int j = 0; j < lista2.getLength(); j++) {
urls2.add (lista2.item(j).getTextContent());
}
StringBuilder builder = new StringBuilder();
for(String s : urls) {
char guillemet = '"';
builder.append(guillemet+s+guillemet);
builder.append(",");
}
builder.deleteCharAt (builder.length()-1);
String chaine=builder.toString();
String x1 = "iris.txt";
String x2 = "out.pdf" ;
String h= enstxfs.get(0).getText();
shell = Runtime.getRuntime().exec(new String[] { "C:\\Program Files\\R\\R-3.0.3\\bin\\Rscript.exe",hs,chaine });
InputStream in = shell.getInputStream();
BufferedWriter out=new BufferedWriter(new FileWriter("file.txt"));
int c;
while ((c = in.read()) != -1) {
out.write((char)c);
}
in.close();
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
JButton b2= new JButton("Cancel");
b2.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
}); |
La variable hs est le chemin vers la source .R
//Voila mon code en R:
Code:
1 2 3 4 5
| args = commandArgs(trailingOnly=TRUE)
df = read.table(args[1], header=TRUE)
pdf('C:/Users/pc/workspace/Memoire_Monia_Clustering/plots/rplot19.pdf')
plot(df)
dev.off() |
et l'autre problème c'est comment utiliser cette liste dans le source .R
merci d'avance