读取中文要转一下码,从8859_1到GBK的转码写中文用properties类就不行,你可以先转成8859再写进去看看一般properties要用工具native2ascii转一下码

解决方案 »

  1.   

    Properties prop = new Properties();
    prop.setProperty("name", new String("中文".getBytes("ISO-8859-1"), "GB2323"));
    是这样么?大虾。
    可写不进去呀:(
      

  2.   

    你需要首先关联到一个file上。
    read:
    Properties pro=new Properties();
    InputStream in=new FileInputStream("FileName");
    pro.load(in);
    in.close();
    write:
    Properties pro=new Properties();
    OutStream out=new FileOutputStream("FileName");
    prop.setProperty("name", new String("中文".getBytes("ISO-8859-1"), "GB2323"));
    pro.store(out,"header");
    in.close();
      

  3.   

    多谢大虾。文件我关联了,写“GB2323”写不进去。
    只是这样时可以写入
    prop.setProperty("name", new String("中文".getBytes("ISO-8859-1"), "GBK"));但打开看中文被显示成“?”
      

  4.   

    String content = new String((prop.getProperty("CONTENT").trim()).getBytes("ISO-8859-1"), "GB2323");是取出中文属性
      

  5.   

    to eci0(eci0) 
    大虾那么怎么将中文属性写进去呢?
    急急急!!!!! 
      

  6.   

    Properties pro=new Properties();
    pro.setProperty("中文key", "中文value");
    ....
    OutputStreamWriter output;
    output = new OutputStreamWriter(new FileOutputStream("file name"), "encoding charset");
    pro.store(output, "title");InputStreamReader input;
    input = new InputStreamReader(new FileInputStream("file name"), "encoding charset");
    pro.load(input);
    pro.getProperty(..., ...);
      

  7.   

    对不起,上面写得好象不对,上面的方法是怎样让castor生成和读取xml文件。
    Properties 好像不用这么繁,它用的是system default encoding.然后,非ASCII字符会被save成:比如"桌面"就是\u684C\u9762
      

  8.   

    to hayai(生命树):
    pro.store(output, "title");
    不行呀。output只能是FileOutputStream类型。
    ????