当前位置 : 主页 > 网页制作 > xml >

代码生成器会用到的xml

来源:互联网 收集:自由互联 发布时间:2021-06-13
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 Except
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;
        
    }
    
    
    
}
上一篇:小程序wxs是作用
下一篇:xml简单知识
网友评论