generatesql.java.svn-base

来自「通讯采集软件」· SVN-BASE 代码 · 共 63 行

SVN-BASE
63
字号
package repeatsql;import java.io.*;import java.util.*;public class GenerateSql {    public GenerateSql() {    }    public static void main(String[] args){        GenerateSql m_sql = new GenerateSql();        String pathname = "D:\\repeatsql\\jssd\\"+ "imp_his_ip"+".txt";        char[] sqlbuffer = new char[4000];        String sqlStr = null;        try{            FileInputStream fs = new FileInputStream(pathname);            BufferedReader br = new BufferedReader(new InputStreamReader(fs));            br.read(sqlbuffer);            fs.close();            sqlStr = new String(sqlbuffer);        }        catch(Exception e){            e.printStackTrace();        }        System.out.println(sqlStr);        System.out.println("length is "+sqlStr.length());        int index = sqlStr.lastIndexOf(";");        String m_String  = sqlStr.substring(0,index+1);        System.out.println("subString = "+m_String);        System.out.println("length 2 = "+m_String.length());        for(int i=2; i<=1662; i++){            String oldString = new String("his_ip_")+new Integer(i-1).toString();            String stringnew = new String("his_ip_")+new Integer(i).toString();            String mm_String = m_String.replaceAll(oldString,stringnew);            m_String = mm_String;            System.out.println("oldString = "+oldString);            System.out.println("stringnew = "+stringnew);            m_sql.WriteToFile("1662imp_his_ip",m_String);            m_sql.WriteToFile("1662imp_his_ip","");        }    }    public static void WriteToFile(String filename,String m_String){        String pathname = "D:\\repeatsql\\jssd\\"+ filename+".txt";        File m_exfile = new File(pathname);        try {            if (!m_exfile.exists()) {                m_exfile.createNewFile();            }            FileWriter fw = new FileWriter(m_exfile, true);            PrintWriter pw = new PrintWriter(fw);            pw.println(m_String);            fw.close();            pw.close();        }        catch (Exception exception) {            exception.printStackTrace();        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?