码迷,mamicode.com
首页 > 其他好文 > 详细

Copy xml 文件

时间:2015-02-03 16:35:02      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

    public static void copyFailFile(String bugID) throws Exception {
        File file = new File(".");
        //get XML file path
        String xmlFilePath = file.getCanonicalPath() + "\\Accounting Client\\results\\Accounting Client.xml";
        //new XML file
        String bugFilePath = file.getCanonicalPath() + "\\Accounting Client\\results\\" + bugID + ".xml";
        //read XML file
        BufferedReader reader = new BufferedReader(new FileReader(new File(xmlFilePath)));
        //write XML file
        BufferedWriter writer = new BufferedWriter(new FileWriter(new File(bugFilePath)));
        
        String line = "";
        StringBuilder sb = new StringBuilder();
        while((line = reader.readLine()) != null) {
            if(line.contains(""")) {
                line = line.replace(""", "\"");
            }else if(line.contains(">")) {
                line = line.replace(">", ">");
            }
            sb.append(line + "\n");
        }
        writer.append(sb.toString());
        writer.flush();
        writer.close();
        reader.close();
    }

 

Copy xml 文件

标签:

原文地址:http://www.cnblogs.com/xriverside/p/4269976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!