Centos7开启端口

1.开放端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

–zone 作用域

–add-port=80/tcp 添加端口/通讯协议

–permanent 永久生效,否则重启失效

2.常用命令

启动:systemctl start firewalld

关闭:systemctl stop firewalld

重启:firewall-cmd --reload

查看防火墙是否开启的状态,以及开放端口的情况

      systemctl status firewalld.service

      firewall-cmd --list-all 

 

String 字符串替换’*’

/**
     * 实际替换动作
     *
     * @param str str
     * @return
     */
    public static String replaceAction(String str) {
        if(isEmpty(str)){
            return "";
        }
        String afterReplaced = "";
        int nameLength = str.length();
        if (nameLength < 3 && nameLength > 0) {
            if (nameLength == 1) {
                afterReplaced = "*";
            } else {
                afterReplaced = str.substring(0,1)+"*";
            }
        } else {
            Integer num1, num2, num3;
            num2 = (new Double(Math.ceil(new Double(nameLength) / 3))).intValue();
            num1 = (new Double(Math.floor(new Double(nameLength) / 3))).intValue();
            num3 = nameLength - num1 - num2;
            String star = org.apache.commons.lang3.StringUtils.repeat("*", num2);
            afterReplaced = str.replaceAll("(.{" + num1 + "})(.{" + num2 + "})(.{" + num3 + "})", "$1" + star + "$3");
        }
        return afterReplaced;
    }