为什么输出不了中文汉字。

解决方案 »

  1.   


    File file=new File("hello.txt");
    byte b[]="欢迎 welcome".getBytes();
    System.out.println(file.getAbsolutePath());
    try {
    FileOutputStream out=new FileOutputStream(file);
    out.write(b);
    out.close();
    FileInputStream in=new FileInputStream(file);
    Reader a;
    int n=0;
    while((n=in.read(b, 0, 2))!=-1)
    {
    String str=new String(b,0,2);

    System.out.printf("%s",str);
    }
    } catch (IOException e) {
    // TODO: handle exception
    System.out.println(e);
    }
    }
      

  2.   

    可以显示啊.
    d:\myjava\hello.txt
    欢迎 welcome
    d:\myjava>
      

  3.   

    D:\workspaces\Tc\hello.txt
    ����� welcome 为什么我的是这样的
      

  4.   

    我把工作空间到项目到工程到类的编码格式都改成GBK就行了。
      

  5.   

    我把工作空间到项目到工程到类的编码格式都改成GBK就行了。