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();
		}
	}




http://blog.csdn.net/fabuler/article/details/46879819

你可能感兴趣的:(cmd)