utf8文件中能不能直接写汉字?
我这样做不行,utf8文件中要用的汉字怎么办,用resourceBundle?
public class test 
{
public static void main(String[] args) 
{
System.out.println("Hello World 中言语 !");
}
}
C:\ww>javac test.java
test.java:5: warning: unmappable character for encoding GBK
                System.out.println("Hello World 涓█璇? !");
                                                    ^
1 warningC:\ww>java test
Hello World 涓█璇? !

解决方案 »

  1.   

    把汉字转成unicode格式。不过,怎么会出现这种情况?你用什么编辑器?
      

  2.   

    String str1 = "Hello World 中言语 !";
    String str3 = new String(str1.getBytes(),"GBK");
    System.out.println(str3);
      

  3.   


    用resourceBundle到是可以解决,但有点麻烦。
    直接这样写System.out.println("Hello World !"+"\u54ac\u7259\u5207\u9f7f");,又影响阅读不知道大家有没有什么好办法编辑utf8文件?
    又要看得懂,又要是utf8编码的方法?
      

  4.   

    除非编辑环境有这种功能,否则,noway
      

  5.   

    unicode + 注释
    -----------------------
    这也可行。但每次为几个汉字就要native2ascii也太麻烦了。