How to determine the currently active code page from a Java console application on Windows?
问题 This is a simple Java application which displays the default code page on Windows: package doscommand; import java.io.IOException; import java.io.InputStream; public class DosCommand { public static void main(String[] args) throws IOException { InputStream in = Runtime.getRuntime().exec("chcp.com").getInputStream(); int ch; StringBuilder chcpResponse = new StringBuilder(); while ((ch = in.read()) != -1) { chcpResponse.append((char) ch); } System.out.println(chcpResponse); // For example: