Properties prop=new Properties();prop.setProperties("key",":");
OutputStream os=new FileOutputStream("prop.properties");
prop.store(os, "更新于:");
os.close();执行后key=\:而不是
key=:

解决方案 »

  1.   


    try
    {
        Properties prop=new Properties(); 
        prop.setProperties("key",":"); 
        OutputStream os=new FileOutputStream("prop.properties"); 
        prop.store(os, "更新于:"); 
        os.close(); }
    catch (FileNotFoundException ex)
    {
       //handle Exception
    }
    catch (IOException ex)
    {
        //handle Exception
    }
      

  2.   

    不是 bug,因为 properties 文件中 = 和 : 都可以作为键值的分隔符,所以自动写入时会加上 \ 进行转义。
      

  3.   

    可以看一下 java.util.Properties 中 load 和 store 两个方法的 API DOC。