Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 运行时特殊字符显示的问题_Java - Fatal编程技术网

Java 运行时特殊字符显示的问题

Java 运行时特殊字符显示的问题,java,Java,我必须很好地展示在java中使用运行时执行的命令的响应 public static String RunCMDshow(String comando){ Runtime R = Runtime.getRuntime(); String resto = ""; try { Process p = R.exec(comando); InputStreamReader isr=new InputStream

我必须很好地展示在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;
    }
我有西班牙语的窗户,当它必须重新编码特殊字符时,比如á,ñ,í 他们像这样拿绳子

埃斯塔德�第178.60.128.59段: Paquetes:enviados=4,recibidos=4,perdidos=0 百分之零点零零, ida和vuelta在milisegundos附近的土地: M�nimo=8毫秒,毫米�ximo=10ms,介质=9ms

我必须在文本窗格上显示Com的结果和特殊字符,因为我必须复制它,而且我对命令如何返回特殊字符有问题


如果必须使用另一种方式执行命令,我会这样做。

在这一行InputStreamReaderp.getInputStream上指定一个字符集;在这里可以看到:我尝试使用InputStreamReaderp.getInputStream、Charset.forNameUTF-8;但是如果这是一个Windows控制台,它应该是ISO-8859-1,我想它可以与InputStreamReader isr=new InputStreamReaderp.getInputStream,Charset.forNameIBM00858一起工作;但是Windows提示符必须是UTF-8,我尝试使用所有字符集,我不知道为什么IBM00858工作我也尝试使用ISO-8859-1,但它也不工作