zoukankan      html  css  js  c++  java
  • java常用的语句

    //判断一个长的字符串中是否包含某一个短的字符串
    if (str1.indexOf(str2) != -1) {
        return true;//存在
    }else {
        return false;
    }
    /**
     * 消息模板关键字替换
     * @param template  消息内容
     * @param map 替换key-value
     * @return
     */
    public static String replaceTemplate(String template, Map<String, Object> map){
        if(!StringUtils.isBlank(template)){
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                template = template.replaceAll(entry.getKey(), entry.getValue().toString());
            }
        }
        return template;
    }
    /**
     * 生产的随机串
     * @param num 长度
     * @return
     */
    public static String genRadomNbr(Integer num) {
        Random random = new Random();
        String result = "";
        for (int i = 0; i < num; i++) {
            result += random.nextInt(10);
        }
        return result;
    }
    /**
     * 组装返回的json数据
     * @param data
     * @param code
     * @param message
     * @return
     */
    public JSONObject assemblyJson(Object data, String code, String message) {
        JSONObject jsonObject = new JSONObject();// 创建对象
        jsonObject.put("data", data);// 数据不为空的时候设置返回数据
        jsonObject.put("message", message);// 设置状态数据
        jsonObject.put("code", code);
        return jsonObject;
    
    }
    //删除某一字符
    public static String deleteStr(String str, char delChar){
        String delStr = "";
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i) != delChar){
                delStr += str.charAt(i);
            }
        }
        return delStr;
    }
  • 相关阅读:
    跑路了
    *CTF 2019 quicksort、babyshell、upxofcpp
    pyspark如何遍历broadcast
    pwn易忘操作原理笔记
    pwn学习之四
    pwn学习之三
    pwn学习之二
    pwn学习之一
    2017GCTF部分writeup
    OD使用教程12
  • 原文地址:https://www.cnblogs.com/gjq1126-web/p/11212834.html
Copyright © 2011-2022 走看看