首页 > 其他 > 详细

Copy xml 文件

时间:2015-02-03 16:33:33      阅读:238      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!