0

I have to show well the response of a Command executed using Runtime in java.

public static String RunCMDshow(String comando){
        Runtime R = Runtime.getRuntime();
        String resto = "";
        try {
            Process p = R.exec(comando);
            InputStreamReader isr=new InputStreamReader(p.getInputStream());
            BufferedReader stdInput = new BufferedReader(isr);
            String s = null;
            while ((s = stdInput.readLine()) != null) {
                resto = resto + "\n" + s;
                System.out.println(s);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return resto;
    }

I have Windows in spanish and when It must Recober special Chars like "á,ñ,í" they take the string like this.

Estad�sticas de ping para 178.60.128.59: Paquetes: enviados = 4, recibidos = 4, perdidos = 0 (0% perdidos), Tiempos aproximados de ida y vuelta en milisegundos: M�nimo = 8ms, M�ximo = 10ms, Media = 9ms

I must show The result of the comand showing the special chars on a TextPane because I must copy that and I have the problem with commands how returns special chars.

If I must use another way to execute the command I will do that.

0 Answers0