jdk1.8 -- Collectors 的使用

2023-11-14

 

 

package com.collector;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;

import com.zpb.video_06.Dish;
import com.zpb.video_06.Dish.Type;

/**
 * @des        Collector API的使用
 *                 三大功能:聚合    分组     统计                          
 * @author  zhao
 * @date    2019年9月22日下午11:53:54
 * 
 */
public class CollectorsAPI {
    
    public static final List<Dish> menu =  Arrays.asList(
            new Dish("pork", false, 800, Dish.Type.MEAT),
            new Dish("beef", false, 700, Dish.Type.MEAT), 
            new Dish("chicken", false, 400, Dish.Type.MEAT),
            new Dish("french fries", true, 530, Dish.Type.OTHER),
            new Dish("rice", true, 350, Dish.Type.OTHER),
            new Dish("season fruit", true, 120, Dish.Type.OTHER), 
            new Dish("pizza", true, 550, Dish.Type.OTHER),
            new Dish("prawns", false, 300, Dish.Type.FISH), 
            new Dish("salmon", false, 450, Dish.Type.FISH));
    
    public static void main(String[] args) {
        //1.求平均值
        testAveragingDouble();
        testaveragingInt();
        testAveragingLong();
        testCollectingAndThen();
        
        //2.统计
        testCounting();
        testGroupByFunction();
        testGroupByFunctionAndCollectors();
        testGroupByFunctionAndAndCollectors();
        testSummarizingInt();
    }
    
    private static void testSummarizingInt() {
        IntSummaryStatistics intSummary = menu.stream().collect(Collectors.summarizingInt(Dish::getCalories));
        Optional.ofNullable(intSummary).ifPresent(System.out::println);
    }
    
    
    private static void testGroupByFunctionAndAndCollectors() {
        System.out.println("...testGroupByFunctionAndCollectors...");
        Map<Type, Double> map = menu.stream().collect(Collectors.groupingBy(Dish::getType,Collectors.averagingDouble(Dish::getCalories)));
        Optional.ofNullable(map.getClass()).ifPresent(System.out::println);        //hashmap 
        //我们得到的是hashMap, 下面把它改成treeMap
        TreeMap<Type, Double> map2 = menu.stream().collect(Collectors.groupingBy(Dish::getType, TreeMap::new, Collectors.averagingDouble(Dish::getCalories)));
        Optional.ofNullable(map2.getClass()).ifPresent(System.out::println);
        
    }
    
    private static void testGroupByFunctionAndCollectors() {
        System.out.println("...testGroupByFunctionAndCollectors...");
        Optional.ofNullable(menu.stream().collect(Collectors.groupingBy(Dish::getType, Collectors.counting())))
        .ifPresent(System.out::println);
        
        //每个分类下卡路里平均值
        Optional.ofNullable(
        menu.stream().collect(Collectors.groupingBy(Dish::getType, Collectors.averagingDouble(Dish::getCalories))))
        .ifPresent(System.out::println);
    }
    private static void testGroupByFunction() {
        System.out.println("...testGroupByFunction...");
        Optional.ofNullable(menu.stream().collect(Collectors.groupingBy(Dish::getType)))
                .ifPresent(System.out::println);
    }
    
    private static void testCounting() {
        System.out.println("...testCounting...");
        Optional.ofNullable(menu.stream().collect(Collectors.counting())).ifPresent(System.out::println);
    }
    private static void testAveragingDouble() {
        System.out.println("...testAveragingDouble...");
        Optional.ofNullable(menu.stream().collect(Collectors.averagingDouble(Dish::getCalories)))
        .ifPresent(System.out::println);
    }
    
    private static void testaveragingInt() {
        System.out.println("...testaveragingInt...");
        Optional.ofNullable(menu.stream().collect(Collectors.averagingInt(Dish::getCalories)))
        .ifPresent(System.out::println);
    }
    
    private static void testAveragingLong() {
        System.out.println("...testAveragingLong...");
        Optional.ofNullable(menu.stream().collect(Collectors.averagingLong(Dish::getCalories)))
        .ifPresent(System.out::println);
    }
    private static void testCollectingAndThen() {
        /**
         * collectingAndThen(Collector<T,A,R> downstream,Function<R,RR> finisher)
         *   第1个参数是: Collector,也就是通过Collectors拿到的集合
         *   第2个参数是:Function,也就是传入2个参数,R RR,返回的是RR
         *  该方法最主要是要用好参数是怎么传入的
         */
        System.out.println("...testCollectingAndThen...");
        
        //1.获取到平均值,然后变成字符串输出
        Optional.ofNullable(menu.stream().
                collect(Collectors.collectingAndThen(Collectors.averagingLong(Dish::getCalories), a->"calories avg is "+a)))
                .ifPresent(System.out::println);
        
        //2.得到指定集合,不能被别人修改
        List<Dish> collect = menu.stream().filter(m->m.getType().equals(Type.MEAT))
            .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
        Optional.ofNullable(collect).orElseGet(ArrayList::new).forEach(System.out::println);
        
    }
    
}

 

package com.collector;

import java.awt.Menu;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.stream.Collectors;

import com.collector.CollectorsAPI1;
import com.zpb.video_06.Dish;
import com.zpb.video_06.Dish.Type;
/**
 * @des                                  
 * @author  zhao
 * @date    2019年9月24日上午12:13:00
 * 
 */
public class CollectorsAPI2 {
    
    static List<Dish> menu = CollectorsAPI1.menu;
    
    public final static void main(String[] args) {
        
        testGroupingByConcurrent();
        testGroupingByConcurrentAndCollectors();
        testGroupingByConcurrentAndSkipAndCollectors();
        testJoining();
        testJoiningAndPrefixAndSuffix();
        testMapping();
        testMaxBy();
        testMinBy();
    }
    
    //maxBy(Comparator<? super T> comparator) 按Comparator比较器规则,选出最大值
    public static void testMaxBy() {
        System.out.println(">>>>>>>>>>>>>>> testMaxBy  >>>>>>>>>>>>>>>");
        menu.stream().collect(Collectors.maxBy(Comparator.comparing(Dish::getCalories)))
            .ifPresent(System.out::println);
    }
    
    //maxBy(Comparator<? super T> comparator) 按Comparator比较器规则,选出最小值
    public static void testMinBy() {
        System.out.println(">>>>>>>>>>>>>>> testMaxBy  >>>>>>>>>>>>>>>");
        menu.stream().collect(Collectors.minBy(Comparator.comparing(Dish::getCalories)))
            .ifPresent(System.out::println);
    }
        
    public static void testMapping() {
        System.out.println(">>>>>>>>>>>>>>> testMapping  >>>>>>>>>>>>>>>");
        /**
         *  mapping(Function<? super T, ? extends U> mapper, Collector<? super U, A, R> downstream) {
         *  第1个参数得到的结果作为第2个参数操作的源数据
         */
        Optional.ofNullable(menu.stream().collect(Collectors.mapping(Dish::getName, Collectors.joining(","))))
                .ifPresent(System.out::println);
                
    }
    
    //连接操作
    public static void testJoining() {
        System.out.println(">>>>>>>>>>>>>>> testJoining()  >>>>>>>>>>>>>>>");
        Optional.ofNullable(menu.stream().map(Dish::getName).collect(Collectors.joining("#")))
                .ifPresent(System.out::println);
    }
    public static void testJoiningAndPrefixAndSuffix() {
        System.out.println(">>>>>>>>>>>>>>> testJoiningAndPrefixAndSuffix()  >>>>>>>>>>>>>>>");
        Optional.ofNullable(menu.stream().map(Dish::getName).collect(Collectors.joining(",","Name[","]")))
        .ifPresent(System.out::println);
    }
    
    public static void testGroupingByConcurrentAndSkipAndCollectors() {
        System.out.println(">>>>>>>>>>>>>>> testGroupingByConcurrentAndSkipAndCollectors()  >>>>>>>>>>>>>>>");
        ConcurrentSkipListMap<Type, Double> skipListMap = 
            menu.stream().collect(Collectors.groupingBy(Dish::getType, ConcurrentSkipListMap::new,Collectors.averagingDouble(Dish::getCalories)));
    
        Optional.ofNullable(skipListMap.getClass()).ifPresent(System.out::println);
        Optional.ofNullable(skipListMap).ifPresent(System.out::println);
                
    }
    
    public static void testGroupingByConcurrentAndCollectors() {
        System.out.println(">>>>>>>>>>>>>>> testGroupingByConcurrentAndCollectors >>>>>>>>>>>>>>>");
        Optional.ofNullable(menu.stream().collect(Collectors.groupingBy(Dish::getType, Collectors.averagingDouble(Dish::getCalories))))
                .ifPresent(System.out::println);
    }
    //1.按类型分类,返回类型是:CurrentMap
    public static void testGroupingByConcurrent() {
        System.out.println(">>>>>>>>>>>>>>> testGroupingByConcurrent >>>>>>>>>>>>>>>");
        Optional.ofNullable(menu.stream().collect(Collectors.groupingByConcurrent(Dish::getType)))
                .ifPresent(System.out::println);
    }
    
}

 

package com.collector;

/**
 * @des                                  
 * @author  zhao
 * @date    2019年9月25日下午8:21:52
 * 
 */
import static com.collector.CollectorsAPI1.menu;

import java.util.Comparator;
import java.util.DoubleSummaryStatistics;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.LongSummaryStatistics;
import java.util.Map;
import java.util.Optional;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;

import com.zpb.video_06.Dish;

public class CollectorsAPI3 {

    public static void main(String[] args) {

        // partitioningBy(Predicate<? super T> predicate) 通过条件判断来分组
        // 注意返回值是map类型的,当key为true时,表示是value中是符合判断条件的list集合,反之则不是
        Map<Boolean, List<Dish>> collect = menu.stream().collect(Collectors.partitioningBy(Dish::isVegetarian));
        Optional.ofNullable(collect).ifPresent(System.out::println);

        // partitioningBy(Predicate<? super T> predicate, Collector<? super T,A,D> downstream)
        // 通过判断条件得到的集合,交给下一个collector进行处理
        Map<Boolean, Double> collect2 = menu.stream()
                .collect(Collectors.partitioningBy(Dish::isVegetarian, Collectors.averagingDouble(Dish::getCalories)));
        Optional.ofNullable(collect2).ifPresent(System.out::println);

        // reducing(BinaryOperator<T> op) 聚合操作(用的是BinaryOperator本身的方法)
        Optional<Dish> collect3 = menu.stream()
                .collect(Collectors.reducing(BinaryOperator.maxBy(Comparator.comparing(Dish::getCalories))));
        collect3.ifPresent(System.out::println);

        // reducing(T identity, BinaryOperator<T> op) T: 返回值类型值, op: 二元操作(怎么运算,用的是BinaryOperator父类BiFunction的方法)
        Integer collect4 = menu.stream().map(Dish::getCalories).collect(Collectors.reducing(0, (d1, d2) -> d1 + d2));
        Optional.ofNullable(collect4).ifPresent(System.out::println);
        
        //reducing(U identity, Function<? super T,? extends U> mapper, BinaryOperator<U> op) 
        //第1个参数:定义类型,
        //第二个参数:定义了第2个参数必须是第1个参数的类型歌者是其子类
        //第三个参数:op: 二元操作(怎么运算,用的是BinaryOperator父类BiFunction的方法)
        menu.stream().collect(Collectors.reducing(0, Dish::getCalories,(d1,d2) -> d1 + d2));
        
        //summarizingDouble(ToDoubleFunction<? super T> mapper) 求集合元素的平均结果
        DoubleSummaryStatistics collect5 = menu.stream().collect(Collectors.summarizingDouble(Dish::getCalories));    //这里发生了隐式转换
        Optional.ofNullable(collect5).ifPresent(System.out::println);
        
        //summarizingInt(ToIntFunction<? super T> mapper) 
        IntSummaryStatistics collect6 = menu.stream().collect(Collectors.summarizingInt(Dish::getCalories));
        Optional.ofNullable(collect5).ifPresent(System.out::println);
        
        //Collectors.summarizingLong
        LongSummaryStatistics collect7 = menu.stream().collect(Collectors.summarizingLong(Dish::getCalories));
        Optional.ofNullable(collect7).ifPresent(System.out::println);
        
        //summingInt(ToIntFunction<? super T> mapper) 求某个元素的合 
        Integer collect8 = menu.stream().collect(Collectors.summingInt(Dish::getCalories));
        Double collect9 = menu.stream().collect(Collectors.summingDouble(Dish::getCalories));
        Long collect10 = menu.stream().collect(Collectors.summingLong(Dish::getCalories));
        Optional.ofNullable(collect8).ifPresent(System.out::println);
        Optional.ofNullable(collect9).ifPresent(System.out::println);
        Optional.ofNullable(collect10).ifPresent(System.out::println);
        
        
        
    }
}

 

 

package com.collector;

/**
 * @des                                  
 * @author  zhao
 * @date    2019年9月25日下午9:36:49
 * 
 */
import static com.collector.CollectorsAPI1.menu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;

import com.zpb.video_06.Dish;
import com.zpb.video_06.Dish.Type;

public class CollectorsAPI4 {

    public static void main(String[] args) {

        // toCollection(Supplier<C> collectionFactory)
        // 参数:只要是Collection的子类即可
        ArrayList<Dish> collect = menu.stream().collect(Collectors.toCollection(ArrayList::new));
        LinkedHashSet<Dish> collect2 = menu.stream().collect(Collectors.toCollection(LinkedHashSet::new));

        // toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super
        // T,? extends U> valueMapper)
        ConcurrentMap<String, Integer> collect3 = menu.stream()
                .collect(Collectors.toConcurrentMap(Dish::getName, Dish::getCalories));
        Optional.ofNullable(collect3).ifPresent(System.out::println);
        System.out.println(">>>>>>>>>>>>>>>>>> 1");
        // toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super
        // T,? extends U> valueMapper, BinaryOperator<U> mergeFunction)
        // 第1个参数:通过Function拿到key
        // 第2个参数:通过Function拿到value
        // 第3个参数:将前面的value进行二次元操作
        ConcurrentMap<String, Integer> collect4 = menu.stream().filter(d -> d.getCalories() > 500)
                .collect(Collectors.toConcurrentMap(Dish::getName, Dish::getCalories, (d1, d2) -> d1 + d2));
        Optional.ofNullable(collect4).ifPresent(System.out::println);
        Optional.ofNullable(collect4.getClass()).ifPresent(System.out::println);
        System.out.println(">>>>>>>>>>>>>>>>>> 2");

        // 对同一类型的值进行++操作
        menu.stream().collect(Collectors.toConcurrentMap(Dish::getType, v -> 1L, (a, b) -> a + b));

        // toConcurrentMap(Function<? super T,? extends K> keyMapper, Function<? super
        // T,? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M>
        // mapSupplier)
        // 由上面可知得到的类型是concurrentHashMap类型,第4个参数就是要转换成哪种map类型
        // 第1个参数:通过Function拿到key
        // 第2个参数:通过Function拿到value
        // 第3个参数:将前面的value进行二次元操作
        // 第4个参数:通过Supplier转换成其它类型
        ConcurrentSkipListMap<Type, Long> collect5 = menu.stream().filter(d -> d.getCalories() > 500).collect(
                Collectors.toConcurrentMap(Dish::getType, v -> 1L, (a, b) -> a + b, ConcurrentSkipListMap::new));

        // toList()
        List<Dish> collect6 = menu.stream().collect(Collectors.toList());
        Optional.ofNullable(collect6).ifPresent(System.out::println);

        // toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends
        // U> valueMapper)
        Map<String, Long> collect7 = menu.stream().collect(Collectors.toMap(Dish::getName, V -> 1L));

        // toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends  U> valueMapper, BinaryOperator<U> mergeFunction)
        Map<String, Long> collect8 = menu.stream().collect(Collectors.toMap(Dish::getName, v -> 1L, (a, b) -> a + b));

        // toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper,
        // BinaryOperator<U> mergeFunction, Supplier<M> mapSupplier)
        menu.stream().collect(Collectors.toMap(Dish::getType, v -> 1L, (a, b) -> a + b,  ConcurrentSkipListMap::new));
        System.out.println(">>>>>>>>>>>>>>>>>> 6");
        
        menu.stream().collect(Collectors.collectingAndThen(Collectors.toMap(Dish::getName, Dish::getCalories), Collections::synchronizedMap));
        
        Set<Dish> collect9 = menu.stream().collect(Collectors.toSet());
        Optional.ofNullable(collect9).ifPresent(System.out::println);
    }
}

 

转载于:https://www.cnblogs.com/MrRightZhao/p/11576067.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jdk1.8 -- Collectors 的使用 的相关文章

  • HashMap不写入数据库

    我尝试在我的数据库中写入 但只写入发件人和消息 我不明白为什么会发生这种情况 我认为问题出在我使用 sendMessage 的地方 我认为问题是我没有什么可以做的读 写其他用户的主键 我在数据库中写入消息的活动 public class M
  • 清理码头 - 删除“不必要”的东西

    我习惯用Jetty http jetty codehaus org jetty 作为我的网络容器 我对我做了什么安装步骤得到原始的焦油球并且清理一些目录和文件从中 我在这里想提出的是 您通常从 Jetty 中删除什么以在生产 登台环境中使用
  • “_加载小部件时出现问题”消息

    加载小部件时 如果找不到资源或其他内容 则会显示 加载小部件时出现问题 就这样 惊人的 此消息保留在主屏幕上 甚至没有说明加载时遇到问题的小部件 我通过反复试验弄清楚了这一点 但我想知道发生这种情况时是否有任何地方可以找到错误消息 Andr
  • 添加动态数量的监听器(Spring JMS)

    我需要添加多个侦听器 如中所述application properties文件 就像下面这样 InTopics Sample QUT4 Sample T05 Sample T01 Sample JT7 注意 这个数字可以多一些 也可以少一些
  • 如何在spring mvc中从控制器名称+操作名称获取映射的URL?

    是否有现有的解决方案可以从 Spring MVC3 中的 控制器名称 操作名称 获取映射的 URL 例如 asp net mvc 或 Rails 中的 UrlHelper 我觉得非常有用 thx 也许 你想要这样的东西 in your Co
  • Grails 2.3.0 自动重新加载不起作用

    我最近将我们的项目升级到 grails 2 3 0 一切工作正常 除了每当我更改代码时自动重新加载都无法工作的问题 这包括所有项目工件 控制器 域 服务 gsps css 和 javascript 文件 我的旧版本 grails 可以正常工
  • Android 自定义视图不能以正确的方式处理透明度/alpha

    我正在绘制自定义视图 在此视图中 我使用两个不同的绘画和路径对象在画布上绘画 我基本上是在绘制两个重叠的形状 添加 Alpha 后 视图中重叠的部分比图像的其余部分更暗 这是不希望的 但我不知道如何解决它 这是我的代码片段 用于展示我如何在
  • 使用 RecyclerView 适配器在运行时更改布局屏幕

    我有两个布局文件 如下所示 如果列表中存在数据 则我显示此布局 当列表为空时 我会显示此布局 现在我想在运行时更改布局 当用户从列表中删除最后一项时 我想将布局更改为第二张图片中显示的 空购物车布局 In getItemCount Recy
  • Java套接字:在连接被拒绝异常时重试的最佳方法?

    现在我正在这样做 while true try SocketAddress sockaddr new InetSocketAddress ivDestIP ivDestPort downloadSock new Socket downloa
  • Firestore - RecycleView - 图像持有者

    我不知道如何编写图像的支架 我已经设置了 2 个文本 但我不知道图像的支架应该是什么样子 你能帮我告诉我图像的文字应该是什么样子才能正确显示吗 holder artistImage setImageResource model getArt
  • 记录骆驼路线

    我的项目中有几个 Camel 上下文 如果可能的话 我想以逆向工程方式记录路线 因为我们希望保持与上下文相关的文档最新 最好的方法是什么 我们倾向于预先实际设计路线 并使用来自EIP book http www eaipatterns co
  • 如何让spring为JdbcMetadataStore创建相应的schema?

    我想使用此处描述的 jdbc 元数据存储 https docs spring io spring integration docs 5 2 0 BUILD SNAPSHOT reference html jdbc html jdbc met
  • Java:正则表达式排除空值

    在问题中here https stackoverflow com questions 51359056 java regexp for a separated group of digits 我得到了正则表达式来匹配 1 到 99 之间的一
  • 将表值参数与 SQL Server JDBC 结合使用

    任何人都可以提供一些有关如何将表值参数 TVP 与 SQL Server JDBC 一起使用的指导吗 我使用的是微软提供的6 0版本的SQL Server驱动程序 我已经查看了官方文档 https msdn microsoft com en
  • Dispatcher-servlet 无法映射到 websocket 请求

    我正在开发一个以Spring为主要框架的Java web应用程序 特别使用Spring core Spring mvc Spring security Spring data Spring websocket 像这样在 Spring 上下文
  • 为什么java中的for-each循环中需要声明变量

    for 每个循环的通常形式是这样的 for Foo bar bars bar doThings 但如果我想保留 bar 直到循环结束 我可以not使用 foreach 循环 Foo bar null Syntax error on toke
  • Android - 9 补丁

    我正在尝试使用 9 块图片创建一个新的微调器背景 我尝试了很多方法来获得完美的图像 但都失败了 s Here is my 9 patch 当我用Draw 9 patch模拟时 内容看起来不错 但是带有箭头的部分没有显示 或者当它显示时 这部
  • Hibernate 和可序列化实体

    有谁知道是否有一个框架能够从实体类中剥离 Hibernate 集合以使它们可序列化 我查看了 BeanLib 但它似乎只进行实体的深层复制 而不允许我为实体类中的集合类型指定实现映射 BeanLib 目前不适用于 Hibernate 3 5
  • Android AutoCompleteTextView 带芯片

    我不确定我是否使用了正确的词语来描述此 UI 功能 但我已附上我希望在我的应用程序中实现的目标的快照 它由 Go SMS 使用 用户在编辑文本中键入联系人 在用户从完成下拉列表中选择联系人后 该联系人将被插入到编辑文本中 如附图所示 编辑文
  • 嵌入式 Jetty - 以编程方式添加基于表单的身份验证

    有没有一种方法可以按如下方式以编程方式添加基于表单的身份验证 我用的是我自己的LdapLoginModule 最初我使用基本身份验证并且工作正常 但现在我想在登录页面上进行更多控制 例如显示徽标等 有没有好的样品 我正在使用嵌入式 jett

随机推荐

  • docker学习1-基本概念

    Docker jar包 环境 镜像 镜像存在docker仓库中 随用随取 无需现配环境 docker通过隔离机制 各个镜像之间互不干扰 docker比vm轻量化 每次只需运行镜像即可 镜像占内存小启动快 虚拟机启动慢 占内存较大 docke
  • oracle一个事务的完整流程分析

    author skate time 2010 09 01 在oracle客户端与服务端建立连接的 并把请求提交给oracle服务端以前分析过 参考如下 http blog csdn net wyzxg archive 2010 08 16
  • 夜莺监控V6初探

    目标 客户用产品可能是功能设计好 也可能是因为响应快稳定可靠 例如滴滴用不了用高德 券商app故障受罚 微信凌晨服务崩溃 所以稳定性建设工作价值是保障客户体验 避免资损 社会负面舆论 故障生命周期处理 围绕故障生命周期 在整个故障定位体系
  • 文件上传漏洞靶场upload-labs学习(pass11-pass15)

    Upload Labs关卡 0x00 Pass11 str ireplace复写绕过 0x01 Pass12 GET方式 00截断 0x02 Pass13 POST方式 00截断 0x03 Pass14 文件头截取判断 0x04 Pass1
  • 游戏测试和软件测试有什么区别?

    针对手游而言 游戏测试的本质是APP 所以不少手游的测试方式与APP测试异曲同工 然而也有所不同 APP更多的是具有一种工具 一款APP好不好用不重要 关键点在于实用 而游戏则具有一种玩具属性 它并不见得实用 但他要符合玩家的好恶 要能让玩
  • 华为OD机试 - 寻找相似单词(Java)

    题目描述 给定一个可存储若干单词的字典 找出指定单词的所有相似单词 并且按照单词名称从小到大排序输出 单词仅包括字母 但可能大小写并存 大写不一定只出现在首字母 相似单词说明 给定一个单词X 如果通过任意交换单词中字母的位置得到不同的单词Y
  • python3 pickle.load 读python2 文件报错, UnicodeDecodeError 和 TypeError

    pickle持久化文件用 python2 7 pickle dump产生 程序升级后用python3 6 读文件报错 UnicodeDecodeError ascii codec can t decode byte 0xc3 in posi
  • 【SVN】svn服务器访问失败【由于连接方在一段时间后没有反应】

    可以很清楚的告诉你 是由于服务器的端口未打开或者你的服务根本没有运行 环境 1 服务器windows2012 2 本机电脑win7 3 svn本地的版本和服务器的版本一致 分为以下两种情况 1 在服务器上可以进行svn的操作 2 在服务器上
  • HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException

    做青橙电商项目的时候 发布项目后登录发现直接报空指针异常 仔细检查代码后发现是dubbo远程框架中service远程调用失败 问题是导包倒错了 报错如下 HTTP Status 500 Request processing failed n
  • 博客第一天>>>>梦开始了

    简单的自我介绍一下哈 新码农上任三把活 gt 自我介绍 大哥大佬牛逼的人们好 我来自广西一所三本大学 当一个想要月入过万的小小码农 梦先慢慢积累 语言目标 从c开始学起 第一个月要把c语言的大概 流程做一遍 先学到会看懂一些C语言代码 其间
  • 串联型PI和并联型PI调节器的比较

    一 PI调节器的种类 图3 4 仿真波形变化情况 串联型PI调节器 1500r min 从图3 1到3 4比较可知 与并联型PI调节器相比 串联型PI调节器的超调量很小 速度环 且动态过程时间短 稳态过程的纹波也相对较小 综合可知 代入串联
  • 【运维笔记】kafka跨域通信代理

    kafka跨域通信代理 场景描述 模拟思路 模拟环境说明 基础环境 kafka版本 环境部署 基础软件安装 编写kafka的docker compose yml文件 环境验证 解决方案 Kafka通信机制 解决思路 代理配置 验证是否满足要
  • 解决python中文乱码问题

    python输出中文乱码的问题相信大家都遇到过 那么应该如何解决呢 一 修改系统变量 依次打开 设置 gt 系统 gt 关于 gt 高级系统设置 gt 环境变量 gt 新建系统变量 新变量的变量名是 PYTHONIOENCODING 变量值
  • 《Win10——如何设置开机自启动项》

    Win10 如何设置开机自启动项 1 为需要自启动的程序创建快捷方式 2 Win R输入 shell startup 按下回车键出现一个文件夹 3 将快捷方式拖入文件夹中
  • Unity Mathf的一些函数

    1 Mathf Lerp float a float b float t 1 1 官方给出的解释为 用t在a和b之间做线性差值 参数t限制在0到1之间 当t 0时返回值为a 当t 1时返回值为b 当t为0 5时返回值为a到b的中间点 1 2
  • Computed 和 Watch 的区别

    1 computed计算属性 作用 1 解决模板中放入过多的逻辑会让模板过重且难以维护的问题 例如两个数据的拼接或字体颜色的判断 2 它支持缓存 只有依赖的数据发生了变化 才会重新计算 例如模板中多次用到数据拼接可以用计算属性 只执行一次计
  • 微信小程序播放音乐并同步一次显示一行歌词

    主要是对于歌词部分的描述 gitee项目仓库地址 https gitee com manster1231 master cloud music 点个star哦 1 总体思路 先在加载页面时异步获取歌词 根据 musicId 我们可以获取到该
  • Nginx proxy_pass反向代理动态端口

    背景 某项目需要播放第三方监控视频 我方访问域名假定为 my area com 第三方的域名假定为 video other com 域名不一致就导致浏览器跨域问题无法播放 且第三方拖拖拉拉不想解决 于是只有我方使用 nginx 做反向代理来
  • [CVPR-23-Highlight] Magic3D: High-Resolution Text-to-3D Content Creation

    目录 Abstract Background DreamFusion High Resolution 3D Generation Coarse to fine Diffusion Priors Scene Models Coarse to
  • jdk1.8 -- Collectors 的使用

    package com collector import java util ArrayList import java util Arrays import java util Collections import java util I