bonjour jai un probleme
certaine commandes dos ne fonctionnent pas dans mon prog
notamment dir,telnet,javac,call
alors que ping marche
voici mon code :
quelqun atil une idee sur e pourquoi du comment ? merci davance.
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 public class Panneau2 extends JPanel{ JTextField ping; JTextArea zone; JLabel lab; Box boiteV = Box.createVerticalBox(); public Panneau2(){ ping = new JTextField(20); zone = new JTextArea(10,40); zone.setBackground(Color.black); zone.setForeground(Color.white); boiteV.add(ping); boiteV.add(new JScrollPane(zone)); add(boiteV); ping.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String exe = ping.getText(); try{ Process proc=Runtime.getRuntime().exec(exe); InputStream entree = proc.getInputStream(); InputStreamReader test = new InputStreamReader(entree); BufferedReader br = new BufferedReader(test); String line = br.readLine(); int exitVal = proc.waitFor(); System.out.println("Valeur de sortie: " + exitVal); while ( line != null & line != ""){ System.out.println(line); zone.append(line + '\n'); line = br.readLine(); } } catch (Exception excpt){zone.append("commande non valide \n");} }}); } }![]()
Partager