Java - Interprete de comandos en java

 
Vista:
Imágen de perfil de Eder

Interprete de comandos en java

Publicado por Eder (11 intervenciones) el 09/07/2016 19:27:57
Hola amigos ayudenme con un cmd en java el problema es que algunos comandos como "cls" "dir" y otros no me los reconoce, este es el codigo que tendo



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
package cmd;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
 
/**
 *
 * @author Herdez
 */
public class Cmd {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)throws IOException {
        // TODO code application logic here
 
 
   System.out.print("Microsoft Windows [Version 10.0.10586]\n");
   BufferedReader in=new BufferedReader (new InputStreamReader(System.in));
   Runtime r=null;
   Process p=null;
   while(true){
 
 
       try{
 
       System.out.print("C:/User/Herdez>");
       String comando = in.readLine();
       r=Runtime.getRuntime();
       p=r.exec(comando);
       BufferedReader stream=new BufferedReader(new InputStreamReader(p.getInputStream()));
       while((stream.readLine())!=null){
       System.out.print(stream.readLine()+"\n");
       }
       }
       catch(IOException e){
       System.out.println("C: Comando no Reconocido \n");
 
       }
      }
 
   }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder