zoukankan      html  css  js  c++  java
  • 剔出insert语句

    package zhidan.zhidan_demo;
    
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.util.Scanner;
    
    public class GetInsertSql {
        
        public static void main(String[] args) throws IOException {
            FileInputStream inputStream = null;
            Scanner sc = null;
            try {
            inputStream = new FileInputStream("D:\project\server\chuangshitest(1)\chuangshitest.sql");
            sc = new Scanner(inputStream, "UTF-8");
            
             //写入中文字符时解决中文乱码问题
            FileOutputStream fos=new FileOutputStream(new File("d:/chuangshi.sql"));
            OutputStreamWriter osw=new OutputStreamWriter(fos, "UTF-8");
            BufferedWriter  bw=new BufferedWriter(osw);
            while (sc.hasNextLine()) {
            String line = sc.nextLine();
            
             if(line.indexOf("INSERT")>-1 && line.indexOf(");")>-1) {
                 System.out.println(line);
                 bw.write(line+"	
    ");
             }
             
             //bw.close();
             //osw.close();
             
            }
            
            
            // note that Scanner suppresses exceptions
            if (sc.ioException() != null) {
            throw sc.ioException();
            }
            } finally {
            if (inputStream != null) {
            inputStream.close();
            }
            if(sc != null) {
                sc.close();
            }
            }
        }
    
    }
  • 相关阅读:
    【APIO2008】免费道路[最小生成树 kruskal]
    【2019.8.13】
    【矩阵】
    [POI2008]BLO-Blockade [tarjan 割点]
    poj1458 最长公共子序列 (动态规划)
    最长上升子序列
    poj1163 数字三角形 (动态规划)
    快速幂 (分治)
    求排列的逆序数(分治)
    快速排序 (分治)
  • 原文地址:https://www.cnblogs.com/longsanshi/p/10682379.html
Copyright © 2011-2022 走看看