Java执行cmd 中文

public static void main(String[] args) {
        try {
            // 执行ping命令
            Process process = Runtime.getRuntime().exec("cmd /c e:&dir");
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK")));
            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

你可能感兴趣的:(Java执行cmd 中文)