结果如图显示;我用了网上的设置编码字符集为utf8,结果还是乱码,我的系统字符集是utf8,netbeans字符集也是utf8,这是怎么回事?该怎么解决?

解决方案 »

  1.   

    图片看不到。
    LZ说的系统字符集是什么意思?
    还有,能确保文件中的编码是UTF-8的么?
      

  2.   

    这个与系统的编码关系不大,主要是你的文件的编码。
    // 给InputStreamReader指定要读取的文件的编码,读取时就不会出现乱码了.
     public class TextFileReader {
        public static void main(String[] args) throws Exception {
            String filename = "source/demo-gb18030.txt";
            String encoding = "gb18030";
            printFile(filename, encoding);
        }    // 打印出文件的文本内容, 使用指定的编码读入文件
        public static void printFile(String filename, String encoding) throws IOException {
            InputStreamReader isr = new InputStreamReader(new FileInputStream(filename), encoding);
            BufferedReader reader = new BufferedReader(isr);
            String line = null;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        }
    }
      

  3.   

    String retxtType1 = new String(retxtType.getBytes("ISO-8859-1"),"utf-8");