Properties p = new Properties();
p.setProperty("sb", sb);
p.setProperty("reportname", reportTitle);
p.setProperty("paramdefault", paramDefault.toString()); try {
PrintStream fw = new PrintStream(new File(request.getSession()
.getServletContext().getRealPath("ebsys/ebfile"),
reportTitle + ".properties")); p.list(fw);
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
properties文件内容:sb=
                    reportname=
                    paramdefault=当写进去的字符串超过一定长度的时候,字符串不全部写进去,以“...”代替
怎么解决?

解决方案 »

  1.   


    p.setProperty("sb", sb.length()<8 ? sb : sb.substring(0,8)+"...");
    p.setProperty("reportname", reportname.length()<8 ? reportname : reportname.substring(0,8)+"...");
    p.setProperty("paramdefault", paramdefault.length()<8 ? paramdefault : paramdefault.substring(0,8)+"...");
      

  2.   

    我写进去的字符串,properties自动给我省略超过的部分,以"..."代替了
    我要完整的信息写进去
      

  3.   


    OutputStream out = new FileOutputStream(f);
        p.setProperty("sb", "aaa");
        p.setProperty("reportname","sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");
    p.setProperty("paramdefault", "c");
        p.store(out, "");
      

  4.   

    p.list(fw);
    这个默认超过40个字符后,行为就和你描述的一样了
      

  5.   

    p.store(out, "");用这个会会出现乱码我系统的编码是“UTF-8”生成的properties文件打开是乱码,,而且用java读的时候也是乱码,,有什么思路吗???
      

  6.   

    类似下面的代码你尝试看看public static void main(String[] args) throws Exception {
    PrintWriter inputStream=new PrintWriter("e:/aa.properties","UTF-8");
    Properties properties=new Properties();
    properties.setProperty("test", "中国");
    properties.list(inputStream);
    inputStream.close();
    }
      

  7.   

    p.setProperty("reportname", reportTitle);
     p.setProperty("paramdefault", paramDefault.toString());reportTitle和paramDefault.toString()打印出来是乱码么?
    如果这里是乱码就转码,然后OutputStream out = new FileOutputStream(f);
        OutputStreamWriter osw = new OutputStreamWriter(out,"utf-8");
        p.setProperty("sb", "是乱码吗");
        p.store(osw, "");
      

  8.   

    你用list会出现字符串超过40 后以“...”出现的情况
      

  9.   

    PrintStream fw = new PrintStream(new File(request.getSession()
    .getServletContext().getRealPath("ebsys/ebfile"),
    reportTitle + ".properties"),"UTF-8"); p.store(fw, "");
    fw.close();以UTF-8编码存进去文件里的内容为:sb=\u8BA2\u5355.create_time\:\u521B\u5EFA\u65E5\u671F,\u8BA2\u5355.accept_order_date\:\u63A5\u53D7\u8BA2\u5355\u65E5\u671F,\u8BA2\u5355.ORDER_NUM\:\u7F16\u7801||daram1\:\u8BA2\u5355.accept_order_date\:\u63A5\u53D7\u8BA2\u5355\u65E5\u671F,daram2\:\u8BA2\u5355.create_time\:\u521B\u5EFA\u65E5\u671F,param3\:\u8BA2\u5355.ORDER_NUM\:\u7F16\u7801
      

  10.   

    String sb = new String(
    file.getProperty("sb").getBytes("ISO8859-1"), "UTF-8");解决了我应该直接读String sb = file.getProperty("sb");