List集合的Stream流式操作实现数据类型转换

news2024/10/5 19:14:12

目录

问题现象:

 问题分析:

解决方法:

拓展:

        1、Collectors.toList()

        2、Collectors.toCollection(ArrayList::new)

        3、Collectors.toCollection(LinkedList::new)

        4、Collectors.toCollection(LinkedHashSet::new)

        5、Collectors.toCollection(HashSet::new)

        6、Collectors.toCollection(TreeSet::new)

        7、Collectors.partitioningBy

        8、【重点】Collectors.groupingBy

        9、Collectors.collectingAndThen

        10、map

        11、【重点】Collectors.toMap

        11.1、Collectors.toMap(key, value)

        11.2、【重点】Collectors.toMap(key, value, distinctStrategy)

        11.3、【重点】Collectors.toMap(key, value, distinctStrategy, returnTypeSupplier)

测试代码:

       1、StreamStringListTransformTest 测试类:

        2、Person实体类:

        3、StreamObjectListTransformTest 测试类:


问题现象:

        最近在项目中,有一些逻辑想用List集合的Stream流式操作来快速实现,但由于之前没做好学习笔记和总结,导致一时间想不起来,只能用本方法来解决,如下:

        可以看出来代码量是比较冗长的,于是就回顾了一下List集合的Stream流式操作的相关知识点;打算打一个代码优化!


 问题分析:

        由上图可以知道,我是想将集合list(List<Map<String, Object>> list )根据元素(Map<String, Object> map)中的key为"infoType"的字段值来作相关的业务逻辑,形成指定的集合(如:List<Map<String, Object>> baseInfoList等),然后再存到map集合(Map<String, Object> exportParams)中去。

        根据这个思路其实就可以使用集合list中的Stream流式操作中的Collectors.groupingBy方法来解决了:
        1、首先对集合list中使用Stream流式操作中的Collectors.groupingBy进行分组(分组依据是元素中的key:"infoType"),形成infoTypeListMap集合(Map<String, List<Map<String, Object>>> infoTypeListMap)。

        2、遍历infoTypeListMap集合,然后将元素存入exportParams集合。


解决方法:

        将上图的代码做如下修改即可:

        exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.BASE_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.EDUCATION_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.TRAIN_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.WORK_EXPERIENCE_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.SALARY_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.FAMILY_CONTACT_INFO.getCode() + "_LIST"), new ArrayList<>());
	    exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.LANGUAGE_INFO.getCode() + "_LIST"), new ArrayList<>());
	    Map<String, List<Map<String, Object>>> infoTypeListMap = list.stream().collect(Collectors.groupingBy(map -> (String)map.get("infoType")));
	    infoTypeListMap.entrySet().stream().forEach(entry->{
		    String key = entry.getKey();
		    List<Map<String, Object>> mapList = entry.getValue();
		    exportParams.put(StrUtil.toCamelCase(key+"_LIST"), mapList);
	    });

拓展:

        文末有我写的测试代码,有助于理解,可直接搬运使用!

        相信小伙伴们都见识到List集合的Stream流式操作的强大了吧,接下来,我就把List集合的Stream流式操作实现数据类型转换的常用方法记录并分享在此,以供自己和大家学习记忆。

        1、Collectors.toList()

list.stream().collect(Collectors.toList());

        作用:可用于克隆/拷贝原list集合。作用相当于以下代码:

new ArrayList<>(list);

        2、Collectors.toCollection(ArrayList::new)

list.stream().collect(Collectors.toCollection(ArrayList::new));

        作用:List<Object> 转为 ArrayList<Object> 。作用相当于以下代码:

new ArrayList<>(list);

        3、Collectors.toCollection(LinkedList::new)

list.stream().collect(Collectors.toCollection(LinkedList::new));

        作用:List<Object> 转为 LinkedList<Object> 。作用相当于以下代码:

new LinkedList<>(list);

        4、Collectors.toCollection(LinkedHashSet::new)

list.stream().collect(Collectors.toCollection(LinkedHashSet::new));

        作用:List<Object> 转为 LinkedHashSet<Object>。作用相当于以下代码:

new LinkedHashSet<>(list);

        5、Collectors.toCollection(HashSet::new)

list.stream().collect(Collectors.toCollection(HashSet::new));

        作用:List<Object> 转为 HashSet<Object> 。作用相当于以下代码:

new HashSet<>(list);

        6、Collectors.toCollection(TreeSet::new)

list.stream().collect(Collectors.toCollection(TreeSet::new));

        作用:List<Object> 转为 TreeSet<Object>。作用相当于以下代码:

new TreeSet<>(list);

        7、Collectors.partitioningBy

list.stream().collect(Collectors.partitioningBy(s -> s.length() > 2));

        作用:List<Object> 转为 Map<Boolean, List<Object>>。

        8、【重点】Collectors.groupingBy

list.stream().collect(Collectors.groupingBy(s -> s));

        作用:List<Object> 转为 Map<Object, List<Object>>。

        9、Collectors.collectingAndThen

list.stream().collect(Collectors.groupingBy(s -> s));

        作用:根据指定条件,将集合中所有元素形成的指定类型的结果集合后,再将结果集合做指定的结果集。如:List<Object> 转为 Map<Object, List<Object>> 再转为 Set<String>返回,如下:

list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(s -> s), Map::keySet));

        10、map

list.stream().collect(Collectors.groupingBy(s -> s));

        作用:根据指定条件,提取集合中所有元素的指定属性/字段,形成新的类型(指定属性/字段的数据类型)集合。如:List<Object> 转为 List<Integer>

list.stream().map(String::length).collect(Collectors.toList());

        11、【重点】Collectors.toMap

        作用:List<Object> 转为 Map<Object, Object>

        具有3个重载方法

        11.1、Collectors.toMap(key, value)

list.stream().collect(Collectors.toMap(str -> str, String::length));

        作用:根据指定条件,提取集合中所有元素的指定属性/字段,形成新的类型(指定属性/字段的数据类型)集合。

        参数说明:

                key:指定元素对象的某个属性作为map结果集合的key值。

                value:指定元素对象的某个属性作为map结果集合的value值。

        缺点:当元素中存在重复的key时,会有如下报错:Duplicate key XX。

        11.2、【重点】Collectors.toMap(key, value, distinctStrategy)

list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str));

        作用:在11.1功能一致,多了一个第三参数,该参数用于配置当出现重复key时,对这些元素的value的操作处理逻辑,可以避免key重复报错问题。

        参数说明:

                distinctStrategy:去重逻辑,当遇到重复key时触发该逻辑。

        11.3、【重点】Collectors.toMap(key, value, distinctStrategy, returnTypeSupplier)

list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str, TreeMap::new));

        参数说明:

         returnTypeSupplier:指定map结果集合的数据类型,通过查询源代码可知:当未指定该参数时,默认返回的是HashMap数据类型;如下:


测试代码:

       1、StreamStringListTransformTest 测试类:

        测试List<String>集合的Stream流式操作,实现数据类型转换的功能:

import java.util.*;
import java.util.stream.Collectors;


/**
 * Stream流的各种数据类型转换操作
 */
public class StreamStringListTransformTest {
	public static void main(String[] args) {
		//List<String>集合原数据
		List<String> list = Arrays.asList("java", "python", "C#","php");

		//1、Collectors.toList()
		// List<String>克隆(代替流)
		List<String> listResult = list.stream().collect(Collectors.toList());
		listResult.forEach(System.out::println);
		System.out.println("--------------");




		//2、Collectors.toCollection(ArrayList::new)
		// List<String> 转为 ArrayList<String>
		ArrayList<String> arrayList = list.stream().collect(Collectors.toCollection(ArrayList::new));
		arrayList.forEach(System.out::println);
		System.out.println("--------------");




		//3、Collectors.toCollection(LinkedList::new)
		// List<String> 转为 LinkedList<String>
		List<String> linkedList = list.stream().collect(Collectors.toCollection(LinkedList::new));
		linkedList.forEach(System.out::println);
		System.out.println("--------------");




		//4、Collectors.toCollection(LinkedHashSet::new)
		// List<String> 转为 LinkedHashSet<String>
		LinkedHashSet<String> linkedHashSet = list.stream().collect(Collectors.toCollection(LinkedHashSet::new));
		linkedHashSet.forEach(System.out::println);//LinkedHashSet是有序的
		System.out.println("--------------");




		//5、Collectors.toCollection(HashSet::new)
		// List<String> 转为 HashSet<String>
		HashSet<String> hashSet = list.stream().collect(Collectors.toCollection(HashSet::new));
		hashSet.forEach(System.out::println);//HashSet是无序的(按hash逻辑自动排序)
		System.out.println("--------------");




		//6、Collectors.toCollection(TreeSet::new)
		// List<String> 转为 TreeSet<String>
		TreeSet<String> treeSet = list.stream().collect(Collectors.toCollection(TreeSet::new));
		treeSet.forEach(System.out::println);//TreeSet是按自然顺序自动排序
		System.out.println("--------------");




		//7、Collectors.partitioningBy:根据指定条件,将集合中所有元素分成key为true或false的两组集合,形成的map集合
		// List<String> 转为 Map<Boolean, List<String>>
		Map<Boolean, List<String>> partitioningByMap = list.stream().collect(Collectors.partitioningBy(s -> s.length() > 2));
		System.out.println(partitioningByMap.toString());
		System.out.println("--------------");




		//8、Collectors.groupingBy:根据指定条件,将集合中所有元素分成key为元素本身的集合,形成的map集合
		//List<String> 转为 Map<String, List<String>>
		Map<String, List<String>> groupingByMap = list.stream().collect(Collectors.groupingBy(s -> s));
		System.out.println(groupingByMap.toString());
		System.out.println("--------------");




		//9、Collectors.collectingAndThen:根据指定条件,将集合中所有元素形成的指定类型的结果集合后,再将结果集合做指定的结果集
		//List<String> 转为 Map<String, List<String>> 再转为 Set<String>
		Set<String> collectingAndThen = list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(s -> s), Map::keySet));
		System.out.println(collectingAndThen.toString());
		System.out.println("--------------");




		//10、map:根据指定条件,提取集合中所有元素的指定属性,形成新的指定集合
		//List<String> 转为 List<Integer>
		List<Integer> lengthList = list.stream().map(String::length).collect(Collectors.toList());
		System.out.println(lengthList.toString());
		System.out.println("--------------");




		//11、Collectors.toMap:根据指定条件,提取集合中所有元素的指定属性,组合成自定义类型的map结果集合
		//List<String> 转为 Map<Integer, String>
		//List<String> 转为 Map<String, Integer>
		//注意:该函数有3个重载方法:
		//      11.1、2个参数(key,value):
		//          第一个参数(元素对象的某个指定属性)作为key。
		//          第二个参数作为value。(缺点:当存在key重复的不同元素时,会有类似以下报错:Duplicate key 王五)
		//      11.2、3个参数(key,value,distinctStrategy):
		//          第一个参数(元素对象的某个指定属性)作为key;
		//          第二个参数作为value;
		//          第三个参数用于配置当出现重复key时,对这些元素的value的操作处理逻辑,可以避免上面的key重复报错问题。
		//      11.2、3个参数(key,value,distinctStrategy,returnTypeSupplier):
		//          第一个参数(元素对象的某个指定属性)作为key;
		//          第二个参数作为value;
		//          第三个参数用于配置当出现重复key时,对这些元素的value的操作处理逻辑,可以避免上面的key重复报错问题。
		//          第四个参数用于设置返回map的数据类型(如:TreeMap、ConcurrentHashMap等),默认是返回HashMap。
		List<String> strList = Arrays.asList("java", "python", "C#","php", "java");
		//List<String> 转为 Map<Integer, String>
//		Map<Integer, String> strList1 = strList.stream().collect(Collectors.toMap(String::length, str -> str));//报错:Duplicate key java
//		System.out.println(strList1.toString());
//		System.out.println("--------------");
		//List<String> 转为 Map<String, Integer>
//		Map<String, Integer> strList2 = strList.stream().collect(Collectors.toMap(str -> str, String::length));//报错:Duplicate key 4
//		System.out.println(strList2.toString());
//		System.out.println("--------------");
		//List<String> 转为 Map<String, Integer>
		Map<String, Integer> strList3 = strList.stream().collect(Collectors.toMap(str -> str, String::length, (first, second) -> second));
		System.out.println(strList3.toString());
		System.out.println("--------------");
		Map<String, Integer> list1 = list.stream().collect(Collectors.toMap(str -> str, String::length));
		System.out.println(list1.toString());
		System.out.println("--------------");
		//List<String> 转为 Map<String, Integer>
		Map<Integer, String> list2 = list.stream().collect(Collectors.toMap(String::length, str -> str));
		System.out.println(list2.toString());
		System.out.println("--------------");
		//List<String> 转为 Map<String, Integer>
		Map<Integer, String> list3 = list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str));
		System.out.println(list3.toString());
		System.out.println("--------------");
		//List<String> 转为 TreeMap<String, Integer>
		TreeMap<Integer, String> list4 = list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str, TreeMap::new));
		System.out.println(list4.toString());
		System.out.println("--------------");
	}
}

        2、Person实体类:

        用于支持的测试:

public class Person {
	private String name;
	private Integer age;

	public Person() {
	}

	public Person(String name, Integer age) {
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Person{" + "name='" + name + '\'' + ", age=" + age + '}';
	}
}

3、StreamObjectListTransformTest 测试类:

        测试List<Object>集合的Stream流式操作,实现数据类型转换的功能:

import xxx.Person;//导入Person实体类

import java.util.*;
import java.util.stream.Collectors;


/**
 * Stream流的各种数据类型转换操作
 */
public class StreamObjectListTransformTest {
	public static void main(String[] args) {
		//List<Object>集合原数据
		List<Person> list = new ArrayList<>();
		list.add(new Person("老六", 20));
		list.add(new Person("王五", 20));
		list.add(new Person("李四", 19));
		list.add(new Person("张三", 18));
		list.add(new Person("钱二", 17));
		list.add(new Person("赵一", 16));


		//1、Collectors.toList()
		// List<Object>克隆(代替流)
		List<Person> listResult = list.stream().collect(Collectors.toList());
		listResult.forEach(System.out::println);
		System.out.println("--------------");




		//2、Collectors.toCollection(ArrayList::new)
		// List<Object> 转为 ArrayList<Object>
		ArrayList<Person> arrayList = list.stream().collect(Collectors.toCollection(ArrayList::new));
		arrayList.forEach(System.out::println);
		System.out.println("--------------");




		//3、Collectors.toCollection(LinkedList::new)
		// List<Object> 转为 LinkedList<Object>
		List<Person> linkedList = list.stream().collect(Collectors.toCollection(LinkedList::new));
		linkedList.forEach(System.out::println);
		System.out.println("--------------");




		//4、Collectors.toCollection(LinkedHashSet::new)
		// List<Object> 转为 LinkedHashSet<Object>
		LinkedHashSet<Person> linkedHashSet = list.stream().collect(Collectors.toCollection(LinkedHashSet::new));
		linkedHashSet.forEach(System.out::println);//LinkedHashSet是有序的
		System.out.println("--------------");




		//5、Collectors.toCollection(HashSet::new)
		// List<Object> 转为 HashSet<Object>
		HashSet<Person> hashSet = list.stream().collect(Collectors.toCollection(HashSet::new));
		hashSet.forEach(System.out::println);//HashSet是无序的(按hash逻辑自动排序)
		System.out.println("--------------");




//		//6、Collectors.toCollection(TreeSet::new)
//		// List<Object> 转为 TreeSet<Object>
//		TreeSet<Person> treeSet = list.stream().collect(Collectors.toCollection(TreeSet::new));
//		treeSet.forEach(System.out::println);
//TreeSet是按单一元素自然顺序自动排序,所以转换时会有类似以下报错:
//  com.stephen.javademo.stream.bo.Person cannot be cast to java.lang.Comparable
//		System.out.println("--------------");




		//7、Collectors.partitioningBy:根据指定条件,将集合中所有元素分成key为true或false的两组集合,形成的map集合
		// List<Object> 转为 Map<Boolean, List<Object>>
		Map<Boolean, List<Person>> partitioningByMap = list.stream().collect(Collectors.partitioningBy(person -> person.getAge() >= 18));
		System.out.println(partitioningByMap.toString());
		System.out.println("--------------");




		//8、Collectors.groupingBy:根据指定条件,将集合中所有元素分成key为元素本身的集合,形成的map集合
		//List<Object> 转为 Map<String, List<Object>>
		Map<String, List<Person>> groupingByMap = list.stream().collect(Collectors.groupingBy(Person::getName));
		System.out.println(groupingByMap.toString());
		System.out.println("--------------");




		//9、Collectors.collectingAndThen:根据指定条件,将集合中所有元素形成的指定类型的结果集合后,再将结果集合做指定的结果集
		//List<Object> 转为 Map<String, List<Object>> 再转为 Set<String>
		Collection<List<Person>> collectingAndThen = list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(Person::getName), Map::values));
		System.out.println(collectingAndThen.toString());
		System.out.println("--------------");




		//10、map:根据指定条件,提取集合中所有元素的指定属性,形成新的指定集合
		//List<Object> 转为 List<String>
		List<String> nameList = list.stream().map(Person::getName).collect(Collectors.toList());
		System.out.println(nameList.toString());
		System.out.println("--------------");
		//List<Object> 转为 List<Integer>
		List<Integer> ageList = list.stream().map(Person::getAge).collect(Collectors.toList());
		System.out.println(ageList.toString());
		System.out.println("--------------");
		//List<Object> 转为 Set<Integer>
		Set<Integer> ageSet = list.stream().map(Person::getAge).collect(Collectors.toSet());
		System.out.println(ageSet.toString());
		System.out.println("--------------");




		//11、Collectors.toMap:根据指定条件,提取集合中所有元素的指定属性,组合成自定义类型的map结果集合
		//List<Object> 转为 Map<Object, Object>
		//注意:该函数有3个重载方法:
		//      11.1、2个参数(key,value):
		//          第一个参数(元素对象的某个指定属性)作为key。
		//          第二个参数作为value。(缺点:当存在key重复的不同元素时,会有类似以下报错:Duplicate key 王五)
		//      11.2、3个参数(key,value,distinctStrategy):
		//          第一个参数(元素对象的某个指定属性)作为key;
		//          第二个参数作为value;
		//          第三个参数用于配置当出现重复key时,对这些元素的value的操作处理逻辑,可以避免上面的key重复报错问题。
		//      11.2、3个参数(key,value,distinctStrategy,returnTypeSupplier):
		//          第一个参数(元素对象的某个指定属性)作为key;
		//          第二个参数作为value;
		//          第三个参数用于配置当出现重复key时,对这些元素的value的操作处理逻辑,可以避免上面的key重复报错问题。
		//          第四个参数用于设置返回map的数据类型(如:TreeMap、ConcurrentHashMap等),默认是返回HashMap。
		//List<Person> 转为 Map<Integer, String>
//		Map<Integer, String> personMap1 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName));//报错:Duplicate key 王五
//		System.out.println(personMap1.toString());
//		System.out.println("--------------");
		//List<Person> 转为 Map<String, Integer>
		Map<String, Integer> personMap2 = list.stream().collect(Collectors.toMap(Person::getName, Person::getAge));
		System.out.println(personMap2.toString());
		System.out.println("--------------");
		//List<Person> 转为 Map<String, Person>
		Map<String, Person> personMap3 = list.stream().collect(Collectors.toMap(Person::getName, person -> person));
		System.out.println(personMap3.toString());
		System.out.println("--------------");

		//List<Person> 转为 Map<Integer, String>
		Map<Integer, String> personMap4 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> nextValue));//(preValue, nextValue) -> nextValue):key重复时,取后者
		System.out.println(personMap4.toString());
		System.out.println("--------------");
		//List<Person> 转为 Map<Integer, String>
		Map<Integer, String> personMap5 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue));//(preValue, nextValue) -> preValue):key重复时,取前者
		System.out.println(personMap5.toString());
		System.out.println("--------------");
		//List<Person> 转为 Map<Integer, String>
		Map<Integer, String> personMap6 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue+"、"+nextValue));//(preValue, nextValue) -> preValue+"、"+nextValue):key重复时,取两者拼接
		System.out.println(personMap6.toString());
		System.out.println("--------------");
		//List<Person> 转为 TreeMap<Integer, String>
		TreeMap<Integer, String> personMap7 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue + "、" + nextValue, TreeMap::new));//(preValue, nextValue) -> preValue+"、"+nextValue):key重复时,取两者拼接
		System.out.println(personMap7.toString());
		System.out.println("--------------");
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1480128.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

长时间佩戴耳机伤耳朵吗?如何使用耳机才能保护耳朵的健康?

我们在购买耳机时&#xff0c;往往会更关注耳机的音质、降噪等参数&#xff0c;却往往忽略了与耳机亲密接触的耳朵的感受。 耳机动听固然重要&#xff0c;但关注耳朵的健康&#xff0c;才能让我们更舒心且长久地舒服使用耳机&#xff0c;恰值3月3日爱耳日&#xff0c;我们一起…

linux nasm汇编中调用printf不报错,但调用scanf报错。抛出了分段错误(核心转储)

当我写了如下汇编时 ; nasm -f elf64 -g -F dwarf charsin.asm ; gcc charsin.o -no-pie -o charsin ; ld -o eatclib eatclib.o ; gdb eatclib[SECTION .data]SPrompt db Enter string data, followed by Enter: ,0IPrompt db Enter an integer value, followed by Enter: ,1…

持安科技亮相张江高科895创业营,总评分第三名荣获「最具创新性企业」!

近日&#xff0c;张江高科895创业营&#xff08;第十三季&#xff09;信息安全专场Demo day&结营仪式在上海集成电路设计产业园圆满落幕。本季创业营通过多种渠道在海内外甄选优秀创业项目&#xff0c;一共择优录取了29家入营&#xff0c;最终甄选出9家代表参加Demo day路演…

three 模型对象、材质

三维向量Vector3与模型位置 点模型Points、线模型Line、网格网格模型Mesh等模型对象的父类都是Object3D &#xff0c;如果想对这些模型进行旋转、缩放、平移等操作&#xff0c;如何实现&#xff0c;可以查询Threejs文档Object3D 对相关属性和方法的介绍。 三维向量Vector3 三…

有道QAnything背后的故事---关于RAG的一点经验分享

近日&#xff0c;我们开源了有道自研的RAG&#xff08;Retrieval Augmented Generation) 引擎QAnything。该引擎允许用户上传PDF、图片、Word、Excel、PowerPoint等多种格式的文档&#xff0c;并实现类似于ChatGPT的互动问答功能&#xff0c;其中每个答案都能精确追溯到相应的文…

降压芯片的工作原理是什么?都有哪些推荐?

降压恒压芯片工作原理&#xff1a; 通过将输入电压降低到合适的电压级别&#xff0c;以供应给LED灯。它采用PWM&#xff08;脉冲宽度调制&#xff09;技术来调节开关管的开关时间&#xff0c;从而实现稳定的输出电压&#xff0c;保持LED灯的亮度稳定。降压恒压芯片涉及降压转换…

SpringBoot【问题 05】PostgreSQL数据库启用SSL后使用默认配置进行数据库连接(Navicat工具与Java程序)

官网SSL说明&#xff1a;https://www.postgresql.org/docs/9.1/libpq-ssl.html 1.配置 1.1 文件 使用SSL需要的4个文件&#xff0c;名称要一致&#xff1a; 客户端密钥&#xff1a;postgresql.keyJava客户端密钥&#xff1a;postgresql.pk8客户端证书&#xff1a;postgresq…

idea 创建打包 android App

1、使用 idea 创建 android 工程 2、 配置构建 sdk 3、配置 gradle a、进入 gradle 官网&#xff0c;选择 install &#xff08;默认是最新版本&#xff09; b、选择包管理安装&#xff0c;手动安装选择下面一个即可 c、安装 sdk 并通过 sdk 安装 gradle 安装 sdk&#xff1a…

软件测试面试:请说一下你工作中发现的最有价值的bug?

这个问题&#xff0c;基本95%的面试都会遇到。究竟面试官想要知道什么呢&#xff1f; 让我们回到这个面试场景来看看。 “说一下你印象最深的bug" 你的脑子里拼命的回想过去遇到的印象深刻或有价值的bug。 乍一眼看&#xff0c;这是一个简答到不起眼的问题。可是同学们…

“智农”-数字乡村可视化

“智农”打造数字乡村可视化&#xff0c;结合乡村区域实际情况&#xff0c;以规划完善乡村机制体系和更好服务乡村振兴为目标&#xff0c;坚持可持续、可复制、可扩展的建设原则&#xff0c;着力解决农村信息孤岛&#xff0c;提高农村种植技术&#xff0c;加快农村信息化和产业…

3,设备无关位图显示

建立了一个类Dib Dib.h #pragma once #include “afx.h” class CDib :public CObject { public: CDib(); ~CDib(); char* GetFileName(); BOOL IsValid(); DWORD GetSize(); UINT GetWidth(); UINT GetHeight(); UINT GetNumberOfColors(); RGBQUAD* GetRGB(); BYTE* GetDat…

three.js 向量叉乘cross

效果&#xff1a; 代码&#xff1a; <template><div><el-container><el-main><div class"box-card-left"><div id"threejs"></div><div></div></div></el-main></el-container>…

EasyRecovery2024免费无需付费版电脑数据恢复软件

一、功能概述 EasyRecovery数据恢复软件是一个功能全面的数据恢复工具&#xff0c;其主要功能包括&#xff1a; 文件恢复&#xff1a;能够恢复各种文件类型&#xff0c;如文档、图片、视频、音频等&#xff0c;满足用户多样化的数据恢复需求。分区恢复&#xff1a;当硬盘分区…

vue3中实现elementPlus表格选中行的上移下移

先看效果&#xff1a; 实现步骤&#xff1a; 1、给el-table添加current-change事件、高亮属性及ref属性 2、给上移下移按钮添加事件 // 定义当前选中的行参数 const currentRow ref<any>(null); // 定义表格的ref const singleTableRef ref(); // 行选中事件 const ha…

将所有字母转化为该字母后的第三个字母,即A->D,B->E

//编写加密程序&#xff0c;规则&#xff1a;将所有字母转化为该字母后的第三个字母&#xff0c;即A->D,B->E,C->F,…Y->B,Z->C //小写字母同上&#xff0c;其他字符不做转化。输入&#xff1a;I love 007 输出&#xff1a;L oryh 007 代码&#xff1a; #inc…

OpenAI划时代大模型——文本生成视频模型Sora作品欣赏(十二)

Sora介绍 Sora是一个能以文本描述生成视频的人工智能模型&#xff0c;由美国人工智能研究机构OpenAI开发。 Sora这一名称源于日文“空”&#xff08;そら sora&#xff09;&#xff0c;即天空之意&#xff0c;以示其无限的创造潜力。其背后的技术是在OpenAI的文本到图像生成模…

day05_用户管理minIO角色分配(页面制作,查询用户,添加用户,修改用户,删除用户,用户头像,查询所有角色,保存角色数据)

文章目录 1 用户管理1.1 页面制作1.2 查询用户1.2.1 需求说明1.2.2 后端接口需求分析SysUserSysUserDtoSysUserControllerSysUserServiceSysUserMapperSysUserMapper.xml 1.2.3 前端对接实现思路sysUser.jssysRole.vue 1.3 添加用户1.3.1 需求说明1.3.2 页面制作1.3.3 后端接口…

Kotlin:协程基础

点击查看&#xff1a;协程基础 中文文档 点击查看&#xff1a;协程基础 英文文档 第一个协程程序 import kotlinx.coroutines.*fun main(){GlobalScope.launch {delay(1000L)//delay 是一个特殊的 挂起函数 &#xff0c;它不会造成线程阻塞&#xff0c;但是会 挂起 协程&…

记一次dockerfile无法构建问题追溯

我有一个dockerfile如下&#xff1a; ENTRYPOINT ["/sbin/tini"&#xff0c;"-g", "--"] CMD /home/scrapy/start.sh 我原本的用意是先启动tini&#xff0c;再执行下面的cmd命令启动start.sh。 为啥要用tini&#xff1f; 因为我的这个docker…

springboot235基于SpringBoot的房屋交易平台的设计与实现

房屋交易平台设计与实现 摘 要 信息数据从传统到当代&#xff0c;是一直在变革当中&#xff0c;突如其来的互联网让传统的信息管理看到了革命性的曙光&#xff0c;因为传统信息管理从时效性&#xff0c;还是安全性&#xff0c;还是可操作性等各个方面来讲&#xff0c;遇到了互…