zoukankan      html  css  js  c++  java
  • Java如何大批量从json数据源中按指定符号隔字符串,并修改、删除数据

    原文出自:https://blog.csdn.net/seesun2012

    package com.seesun2012.com;
    
    /**
     * Java大批量修改、删除数据,按指定标识符分隔字符串
     * 
     * @author 张擎宇
     *
     */
    public class AppointSeparate
    {
        public static void main(String[] args) 
        {
            //定义加入有一万条数据要被处理
            int aa = 10000;
            String[] aaStr = new String[aa];
            //获取每一个id到String[]字符串数组中
            for (int i = 0; i < aa; i++) {
                aaStr[i] = "" + i;
                splitStr(aaStr[i]);
            }   
        }
    
        //分隔JSON数据源中的数据,此处使用split方法去掉“,”号
        public static void splitStr(String id) 
        {
            /**
    		 *
    		 * 将分隔开的数据保存至String[]数组中,以下几种转移字符必须加上"\"作为判断转移符标志
             * String.split("\.");
             * String.split("\|");
             * String.split("|");    //将会分隔成一个一个的字符,并且包含空格在内
    		 *
    		 */
            String[] str = id.split(",");
            //接收分隔后的字符串数组长度
            String[] strAt = new String[str.length];
            //循环遍历得出结果
            for (int i = 0; i < str.length; i++) {
                strAt[i] = "'"+ str[i] +"'";    //此时的strAt[]为,strAt['0'~'9999'],带上单引号
            }
            for (String s : strAt) {
                //如果对数据库操作,大批量更新、删除操作
                String sql = "select * from t_user where u_id=" + s;
                System.out.println(sql);
            }
        }
    }
    
  • 相关阅读:
    长沙雅礼中学集训-------------------day1(内含day0)
    17年 5月份刷题版
    manecher_回文串;
    后缀数组
    湖南集训
    好像又好久没更了;计算课noip模拟赛;
    dp的练习题;
    oj1638
    【noi】植物大战僵尸
    #日常吐槽
  • 原文地址:https://www.cnblogs.com/seesun2012/p/9214768.html
Copyright © 2011-2022 走看看