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

代码生成器会用到的xml

时间:2019-10-20 01:12:40      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:except   otf   erp   tostring   package   throw   footer   oid   exce   

package com.gzcgxt.erp.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.junit.Test;

public class MapperXML {
    
    @Test
    public void test1() throws Exception {
        
        String header= newxml();
        
        String footer= old();
        
        StringBuffer sb=new StringBuffer();
        
        sb.append(header).append(footer);
        
        File f=new File("d:/UserMapper.xml");
        
        FileOutputStream out=new FileOutputStream(f);
        
        out.write(sb.toString().getBytes());
        
        out.close();
        
    }
    
    
    public String old() throws Exception
    {
        File f=new File("c:/UserMapper.xml");
        
        FileInputStream in=new FileInputStream(f);
        
        byte[] buffer=new byte[1024];
        
        int len=-1;
        
        StringBuffer sb=new StringBuffer();
        while((len=in.read(buffer))!=-1)
        {
            String s=new String(buffer,0,len);
            sb.append(s);
        }
        
        in.close();
        
        String[] arr = sb.toString().split("</resultMap>");
        
        return arr[1];
        
    }
    
    
    public String newxml() throws Exception
    {
        File f=new File("e:/UserMapper.xml");
        
        FileInputStream in=new FileInputStream(f);
        
        byte[] buffer=new byte[1024];
        
        int len=-1;
        
        StringBuffer sb=new StringBuffer();
        while((len=in.read(buffer))!=-1)
        {
            String s=new String(buffer,0,len);
            sb.append(s);
        }
        
        in.close();
        
        String[] arr = sb.toString().split("</resultMap>");
        
        String s= arr[0];
        
        s=s+"</resultMap>";
        
        return s;
        
    }
    
    
    
}

 

代码生成器会用到的xml

标签:except   otf   erp   tostring   package   throw   footer   oid   exce   

原文地址:https://www.cnblogs.com/hua900822/p/11706372.html

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