栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java读取SQL文件中的创建表名

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java读取SQL文件中的创建表名

题目:读取一个sql文件里面的所有创建表名,记录下来

public static void main(String[] args) throws Exception {
    FileReader fileReader = new FileReader("E:/wen/zjs_szhgg_nw_tem.sql");
    BufferedReader reader = new BufferedReader(fileReader);
    int x = 0;
    String line = null;
    ArrayList strings = new ArrayList<>();
    while ((line = reader.readLine()) != null) {
        if (line.contains("CREATE TABLE")) {
            x++;
            //System.out.println(line);
            String[] s1 = line.split("`");
            for (int i = 0; i < s1.length; i++) {
                if (i == 1) {
                    //System.out.println(s1[1]);
                    strings.add(s1[1]);
                }
            }
        }
    }
    System.out.println(x);
    System.out.println(strings);
    reader.close();
}

执行结果

7
[ap_adapt_task, core_account, core_account_move_history, core_act_lock, core_actext, core_config, core_dasvc_log]

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/770739.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号