import java.io.*;public class InputStreamReaderDemo { public static void main(String[] args) throws IOException { String ZERO = "00000000"; String x = "江西"; byte[] bs = x.getBytes("GB2312"); //如果不采用默认的UTF-8格式编码,那么一个汉字相当于两个字节,一个字节就是8个二进制数(8bit) System.out.println(bs.length+"-------------"); for (int i = 0; i < bs.length; i++) { String s = Integer.toBinaryString(bs[i]); System.out.println(s+"33333"); if (s.length() > 8) { s = s.substring(s.length() - 8); } else if (s.length() < 8) { s = ZERO.substring(s.length()) + s; } System.out.println(s); } }}