反射应用简单案例

day40

反射应用

案例

1.万能数组扩容

设置泛型的copyof仅支持引用数据类型,即任意类型,直接new数组不行,利用反射实现扩容;

打印调用toString也进行编写,利用StringBuffer或者StringBiulder进行字符串拼接

public class Test01 {

	public static void main(String[] args) {
		//引用数据类型
		String[] ss = {"小小","大大","奇奇","怪怪","奇男子"};
		String[] newSS = MyArrays.copyOf(ss, 8);
		System.out.println(MyArrays.toString(newSS));
		//基本数据类型
		int[] is = {1,2,3,4,5};
		int[] newIS = MyArrays.copyOf(is, 8);
		System.out.println(MyArrays.toString(newIS));
	}
}

对前面学习的数组,编写的工具类补充

/**
 * 史上最牛逼的数组工具类
 * @author 奇男子
 * @version 1.0
 */
public class MyArrays {

	/**
	 * 数组的排序
	 * @param a 目标数组
	 */
	public static void sort(int[] a){
		for (int i = 0; i < a.length-1; i++) {
			for (int j = 0; j < a.length-1-i; j++) {
				if(a[j] > a[j+1]){
					int temp = a[j];
					a[j] = a[j+1];
					a[j+1] = temp;
				}
			}
		}
	}
	
	/**
	 * 数组的查找,必须先排序,在查找
	 * @param a 目标数组
	 * @param key 需要查找的键
	 * @return 如果搜索的元素包含在数组中就返回元素的下标; 否则,返回(-插入点-1)
	 */
	public static int binarySearch(int[] a,int key){
		int start = 0;
		int end = a.length-1;
		while(start <= end){
			int mid = (start+end)/2;
			if(key < a[mid]){
				end = mid-1;
			}else if(key > a[mid]){
				start = mid+1;
			}else{
				return mid;
			}
		}
		return -start-1;
	}
	
	/**
	 * 拷贝数组
	 * @param original 目标数组
	 * @param newLength 新数组的长度
	 * @return 新数组
	 */
	public static int[] copyOf(int[] original, int newLength){
		
		int copyLength = original.length;
		if(copyLength > newLength){
			copyLength = newLength;
		}
		
		int[] newArr = new int[newLength];
		
		for (int i = 0; i < copyLength; i++) {
			newArr[i] = original[i];
		}
		return newArr;
	}
	
	/**
	 * 引用数据类型数组的扩容(不支持基本数据类型)
	 * @param original
	 * @param newLength
	 * @return
	 */
	public static <T> T[] copyOf(T[] original , int newLength){
		
		int copyLength = original.length;
		if(copyLength > newLength){
			copyLength = newLength;
		}
		
		//获取元素的类型
		Class<? extends Object[]> clazz = original.getClass();//String[].class
		Class<?> componentType = clazz.getComponentType();//String.clss
		
		//利用反射创建数组
		@SuppressWarnings("unchecked")
		T[] ts = (T[]) Array.newInstance(componentType, newLength);
		
		//遍历源数组,将数据复制到新数组中
		for (int i = 0; i < copyLength; i++) {
			//获取源数组的数据
			Object element = Array.get(original, i);
			//赋值给新数组
			Array.set(ts, i, element);
		}
		return ts;
	}
	
	/**
	 * 拷贝区间数组
	 * @param original 目标数组
	 * @param from 开始下标-包含
	 * @param to 结束下标 - 排他
	 * @return 新数组
	 */
	public static int[] copyOfRange(int[] original, int from, int to){
		
		int newLength = to-from;
		int[] newArr = new int[newLength];
		
		int index = 0;
		for (int i = from; i < to; i++) {
			newArr[index++] = original[i];
		}
		return newArr;
	}
	
	/**
	 * 替换全部元素
	 * @param a 目标数组
	 * @param val 替换的值
	 */
	public static void fill(int[] a, int val){
		fill(a, 0, a.length, val);
	}
	
	/**
	 * 替换区间元素
	 * @param a 目标数组
	 * @param fromIndex 开始下标 - 包含
	 * @param toIndex 结束下标 - 排他
	 * @param val 替换的值
	 */
	public static void fill(int[] a, int fromIndex, int toIndex, int val){
		for (int i = fromIndex; i < toIndex; i++) {
			a[i] = val;
		}
	}
	
	/**
	 * 将数组转换为字符串
	 * @param a 目标数组
	 * @return 转换后的字符串
	 */
	public static String toString(int[] is) { 
		StringBuffer sb = new StringBuffer();
		
		sb.append("[");
		
		for (int element : is) {
			if(sb.length() != 1){
				sb.append(",");
			}
			sb.append(element);
		}
		sb.append("]");
		return sb.toString();
	}
	
	/**
	 * 将数组转换为字符串
	 * @param a 目标数组
	 * @return 转换后的字符串
	 */
	public static <T> String toString(T[] a){
		
		StringBuffer sb = new StringBuffer();
		
		sb.append("[");
		
		for (int i = 0; i < Array.getLength(a); i++) {
			if(sb.length() != 1){
				sb.append(",");
			}
			Object element = Array.get(a, i);
			sb.append(element);
		}
		
		sb.append("]");
		return sb.toString();
	}
	
}

2.业务与逻辑分离的思想

需求:

用户选择获取数据的方式(本地数据、网络数据)

实现
版本01

版本01:if-else直接实现

public class Test01 {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		System.out.println("请选择获取数据的方式:");
		System.out.println("1-获取本地数据");
		System.out.println("2-获取网络数据");
		int num = scan.nextInt();
		
		if(num == 1){
			
			System.out.println("请填写需要拷贝文件的路径:");
			String path = scan.next();
			File file = new File(path);
			BufferedInputStream bis = null;
			BufferedOutputStream bos = null;
			try {
				bis = new BufferedInputStream(new FileInputStream(path));
				bos = new BufferedOutputStream(new FileOutputStream(file.getName()));
				
				byte[] bs = new byte[1024];
				int len;
				while((len=bis.read(bs)) != -1){
					bos.write(bs, 0, len);
				}
				
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				if(bis != null){
					try {
						bis.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				if(bos != null){
					try {
						bos.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
			
			
		}else if(num == 2){
			
			//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpg
			System.out.println("请填写下载图片的网址:");
			String path = scan.next();
			
			try {
				//创建链接对象
				URL url = new URL(path);
				//获取连接对象
				HttpURLConnection connection = (HttpURLConnection) url.openConnection();
				
				//设置参数
				connection.setConnectTimeout(5000);//设置连接超时时间
				connection.setReadTimeout(5000);//设置读取数据超时时间
				connection.setDoInput(true);//设置是否允许使用输入流
				connection.setDoOutput(true);//设置是否允许使用输出流
				
				//获取响应状态码
				int code = connection.getResponseCode();
				if(code == HttpURLConnection.HTTP_OK){
					
					//文件名
					String fileName = path.substring(path.lastIndexOf("/")+1);
					
					BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
					BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
					byte[] bs = new byte[1024];
					int len;
					while((len = bis.read(bs)) != -1){
						bos.write(bs, 0, len);
					}
					
					bis.close();
					bos.close();
					
				}else if(code == HttpURLConnection.HTTP_NOT_FOUND){
					System.out.println("页面未找到");
				}
			} catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}
		
		scan.close();
	}
}
版本02

版本02:简单分离,优化if-else问题

优化:使用类、接口哪个更好?

注意:

如果就只是固定功能或者说DataSource仅是有抽象方法就用接口更好

如果需要添加新的功能用类更好

public class Test01 {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		System.out.println("请选择获取数据的方式:");
		System.out.println("1-获取本地数据");
		System.out.println("2-获取网络数据");
		int num = scan.nextInt();
		
		if(num == 1){
			
			LocalDataSource dataSource = new LocalDataSource();
			dataSource.getDataSource();
			
			
		}else if(num == 2){
			
			NetworkDataSource dataSource = new NetworkDataSource();
			dataSource.getDataSource();
		}
		
		scan.close();
	}
}

数据源

public abstract class DataSource {

	public abstract void getDataSource();
	
}

//获取本地资源的类
public class LocalDataSource extends DataSource{

	private Scanner scan;
	
	public LocalDataSource() {
		scan = new Scanner(System.in);
	}
	
	@Override
	public void getDataSource() {
		
		System.out.println("请填写需要拷贝文件的路径:");
		String path = scan.next();
		File file = new File(path);
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		try {
			bis = new BufferedInputStream(new FileInputStream(path));
			bos = new BufferedOutputStream(new FileOutputStream(file.getName()));
			
			byte[] bs = new byte[1024];
			int len;
			while((len=bis.read(bs)) != -1){
				bos.write(bs, 0, len);
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(bis != null){
				try {
					bis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(bos != null){
				try {
					bos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}

//获取网络资源的类
public class NetworkDataSource extends DataSource{

	private Scanner scan;
	
	public NetworkDataSource() {
		scan = new Scanner(System.in);
	}

	@Override
	public void getDataSource() {
		//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpg
		System.out.println("请填写下载图片的网址:");
		String path = scan.next();
		
		try {
			//创建链接对象
			URL url = new URL(path);
			//获取连接对象
			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
			
			//设置参数
			connection.setConnectTimeout(5000);//设置连接超时时间
			connection.setReadTimeout(5000);//设置读取数据超时时间
			connection.setDoInput(true);//设置是否允许使用输入流
			connection.setDoOutput(true);//设置是否允许使用输出流
			
			//获取响应状态码
			int code = connection.getResponseCode();
			if(code == HttpURLConnection.HTTP_OK){
				
				//文件名
				String fileName = path.substring(path.lastIndexOf("/")+1);
				
				BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
				BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
				byte[] bs = new byte[1024];
				int len;
				while((len = bis.read(bs)) != -1){
					bos.write(bs, 0, len);
				}
				
				bis.close();
				bos.close();
				
			}else if(code == HttpURLConnection.HTTP_NOT_FOUND){
				System.out.println("页面未找到");
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
版本03

版本03:在原有基础,新增功能

对菜单和数据源都在数据中心配合配置文件进行初始,可维护性更好

将菜单信息放在配置文件,再取出来存在一个集合里(ps:代码中的数据中心dataSource)
再打印查看展示

本地资源,网络资源路径放在配置文件
初始化数据源的循环获取对象,放在dataSource

添加其他功能,即新增功能,更改配置文件

public class Test01 {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		showMenu();
		int num = scan.nextInt();
		
		DataSource dataSource = getDataSourceObject(num);
		dataSource.getDataSource();
		
		scan.close();
	}
	
	public static void showMenu(){
		System.out.println("请选择获取数据的方式:");
		ArrayList<String> menulist = DataCenter.menuList;
		for (String element : menulist) {
			System.out.println(element);
		}
	}
	
	public static DataSource getDataSourceObject(int num){
		DataSource dataSource = DataCenter.dataSourceList.get(num-1);
		return dataSource;
	}
}

数据中心

//数据中心
public class DataCenter {

	public static final ArrayList<String> menuList;
	public static final ArrayList<DataSource> dataSourceList;
	
	//初始化菜单数据
	static{
		
		menuList = new ArrayList<>();
		
		Properties p = new Properties();
		try {
			p.load(DataCenter.class.getClassLoader().getResourceAsStream("menuConfig.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		String data = p.getProperty("data");
		String[] split = data.split(",");
		Collections.addAll(menuList, split);
	}
	
	//初始化数据源数据
	static{
		
		dataSourceList = new ArrayList<>();
		
		Properties p = new Properties();
		try {
			p.load(DataCenter.class.getClassLoader().getResourceAsStream("dataSourceConfig.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		String data = p.getProperty("data");
		String[] split = data.split(",");
		for (String classPath : split) {
			try {
				Class<?> clazz = Class.forName(classPath);
				DataSource dataSouce = (DataSource) clazz.newInstance();
				dataSourceList.add(dataSouce);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}		
		}
	}
}

配置文件

menuConfig.properties

注意:写进去不是中文显示为正常现象

data=1-\u83B7\u53D6\u672C\u5730\u6570\u636E,2-\u83B7\u53D6\u7F51\u7EDC\u6570\u636E,3-\u83B7\u53D6\u5176\u4ED6\u6570\u636E

dataSourceConfig.properties

data=com.qf.reflex02.LocalDataSource,com.qf.reflex02.NetworkDataSource,com.qf.reflex02.OtherDataSource

数据源

public abstract class DataSource {

	public abstract void getDataSource();
	
}

//获取本地资源的类
public class LocalDataSource extends DataSource{

	private Scanner scan;
	
	public LocalDataSource() {
		scan = new Scanner(System.in);
	}
	
	@Override
	public void getDataSource() {
		
		System.out.println("请填写需要拷贝文件的路径:");
		String path = scan.next();
		File file = new File(path);
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		try {
			bis = new BufferedInputStream(new FileInputStream(path));
			bos = new BufferedOutputStream(new FileOutputStream(file.getName()));
			
			byte[] bs = new byte[1024];
			int len;
			while((len=bis.read(bs)) != -1){
				bos.write(bs, 0, len);
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(bis != null){
				try {
					bis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(bos != null){
				try {
					bos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}

//获取网络资源的类
public class NetworkDataSource extends DataSource{

	private Scanner scan;
	
	public NetworkDataSource() {
		scan = new Scanner(System.in);
	}

	@Override
	public void getDataSource() {
		//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpg
		System.out.println("请填写下载图片的网址:");
		String path = scan.next();
		
		try {
			//创建链接对象
			URL url = new URL(path);
			//获取连接对象
			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
			
			//设置参数
			connection.setConnectTimeout(5000);//设置连接超时时间
			connection.setReadTimeout(5000);//设置读取数据超时时间
			connection.setDoInput(true);//设置是否允许使用输入流
			connection.setDoOutput(true);//设置是否允许使用输出流
			
			//获取响应状态码
			int code = connection.getResponseCode();
			if(code == HttpURLConnection.HTTP_OK){
				
				//文件名
				String fileName = path.substring(path.lastIndexOf("/")+1);
				
				BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
				BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
				byte[] bs = new byte[1024];
				int len;
				while((len = bis.read(bs)) != -1){
					bos.write(bs, 0, len);
				}
				
				bis.close();
				bos.close();
				
			}else if(code == HttpURLConnection.HTTP_NOT_FOUND){
				System.out.println("页面未找到");
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

//新增功能的类
public class OtherDataSource extends DataSource{

	@Override
	public void getDataSource() {
		System.out.println("获取其他数据");
	}

}

3.操作注解

简单涉及注解开发,没有遵循注解规范就报错,当然这里处理是随便抛的异常

注意:这里为前面反射获取注解信息及实际运用做了补充

工具类里,利用反射,设置权限,获取注解,属性的数据拿到
数据字符串拼接用StringBuilder或者Strinngbuffer

//表
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TableInfo {
	
	String name();
}
//属性
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldInfo {
	String name();
	String type();
}

学生类

添加注解

package com.qf.reflex03;

@TableInfo(name="s_student")
public class Student {

	@FieldInfo(name="s_name",type="varchar")
	private String name;
	
	@FieldInfo(name="s_sex",type="varchar")
	private String sex;
	
	@FieldInfo(name="s_age",type="int")
	private int age;
	
	public Student() {
	}

	public Student(String name, String sex, int age) {
		this.name = name;
		this.sex = sex;
		this.age = age;
	}

	public String getName() {
		return name;
	}

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

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

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

	@Override
	public String toString() {
		return "Student [name=" + name + ", sex=" + sex + ", age=" + age + "]";
	}
}

工具类

public class DBUtil {

	public static String generateInsertSQL(Object obj){
		
		Class<? extends Object> clazz = obj.getClass();
		
		//获取表名
		TableInfo tableInfo = clazz.getAnnotation(TableInfo.class);
		if(tableInfo == null){
			throw new RuntimeException();
		}
		String tableName = tableInfo.name();
		
		StringBuffer names = new StringBuffer();
		StringBuffer values = new StringBuffer();
		
		//获取属性数据
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			field.setAccessible(true);
			
			FieldInfo fieldInfo = field.getAnnotation(FieldInfo.class);
			String name = fieldInfo.name();
			String type = fieldInfo.type();
			
			if(names.length() != 0){
				names.append(",");
			}
			names.append(name);
			
			try {
				
				if(values.length() != 0){
					values.append(",");
				}
				
				Object fieldData = field.get(obj);
				if(type.equals("varchar")){
					values.append("'");
				}
				values.append(fieldData);
				if(type.equals("varchar")){
					values.append("'");
				}
				
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		
		String sql = "INSERT INTO " + tableName + "(" + names.toString() + ") VALUES(" + values.toString() + ");";
		return sql;
	}
	
}

测试类

public class Test01 {

	public static void main(String[] args) {
		
		Student stu = new Student("奇男子", "男", 18);
		
		String sql = DBUtil.generateInsertSQL(stu);
		System.out.println(sql);
		//INSERT INTO s_student(s_name,s_sex,s_age) VALUES('奇男子','男',18);
	}
}

总结

1.反射案例 – 万能数组扩展
注意:
1.泛型的使用

2.反射案例 – 业务与逻辑分离的思想
注意:
1.理解思想
2.灵活使用配置文件
3.理解数据中心DataCenter

3.反射案例 – 操作注解
注意:
1.理解注解是可以给类、属性、方法提供额外信息

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Mamba 学习

Vision Mamba U-Mamba 以后的趋势&#xff1a; 1.Mamba模型机机制上和transform一样&#xff0c;但是参数量上做了改进&#xff0c;可以直接替代 2.vision上可以实时处理

视频太大怎么压缩变小?8种方法随时压缩视频大小

视频太大怎么压缩变小&#xff1f;视频压缩方式分为两种&#xff0c;有损压缩和无损压缩&#xff0c;什么是有损什么是无损压缩&#xff0c;什么时候视频用无损压缩更好&#xff1f;什么时候用有损压缩更好&#xff1f;如何调整视频参数实现基本无损压缩&#xff1f; 今天就借助…

小红书笔记写作方法和技巧分享,纯干货!

很多小伙伴感叹小红书笔记流量就是一个玄学&#xff0c;有时精心撰写的笔记却没有人看&#xff0c;自己随便写的笔记却轻轻松松上热门。实际上你还是欠点火候&#xff0c;小红书笔记写作是有一套方法和技巧的&#xff0c;总归是有套路的&#xff0c;如果你不知道&#xff0c;请…

数仓建模—物理数据模型

文章目录 数仓建模—物理数据模型什么是物理数据模型物理数据模型示例如何构建物理数据模型物理数据模型与逻辑数据模型逻辑模型和物理模型之间有什么关系逻辑数据模型的好处物理数据模型的好处数仓建模—物理数据模型 前面我们讲了数据模型和逻辑数据模型,你可以参考前面的文…

【JAVA进阶篇教学】第四篇:JDK8中函数式接口

博主打算从0-1讲解下java进阶篇教学&#xff0c;今天教学第四篇&#xff1a;JDK8中函数式接口。 在 Java 8 中&#xff0c;函数式接口是指只包含一个抽象方法的接口。这种接口可以用作 Lambda 表达式的类型&#xff0c;从而使得函数式编程在 Java 中变得更加方便和灵活。下面…

【题解】NC398 腐烂的苹果(多源BFS)

https://www.nowcoder.com/practice/54ab9865ce7a45968b126d6968a77f34?tpId196&tqId40529&ru/exam/oj 从每个腐烂的苹果开始使用广度优先遍历&#xff08;bfs&#xff09; class Solution {int n, m;int dx[4] {0, 0, 1, -1};int dy[4] {1, -1, 0, 0};vector<v…

C++ STL 容器 deque

目录 1. deque 对象1.1 内部表示1.2 底层数据结构1.3 分段连续1.4 重新分配 2. deque 迭代器 本文测试环境 gcc 13.1 1. deque 对象 1.1 内部表示 deque 为我们提供了一个双端队列&#xff0c;即可以在队头进行 push、pop&#xff0c;可以在队尾进行 push、pop deque 容器擅…

电弧的产生机理

目录&#xff1a; 1、起弧机理 2、电弧特点 3、电弧放电特点 4、实际意义 1&#xff09;电力开关装置 2&#xff09;保险丝 1、起弧机理 电弧的本质是一种气体放电现象&#xff0c;可以理解为绝缘情况下产生的高强度瞬时电流。起弧效果如下图所示&#xff1a; 在电场的…

pyplot+pandas实现操作excel及画图

1、安装jupyter lab pip install jupyterlab # 启动 建议在指定的项目文件夹下 开启cmd窗口并执行 jupyter lab 启动后会自动打开浏览器访问 2、安装依赖 pip install matplotlib pip install xlrd pip install pandas 3、读取excel import pandas as pddf pd.read_excel(hi…

一文带你了解什么是国际短信

什么是国际短信&#xff1f; 国际短信&#xff0c;也叫国际短消息&#xff0c;是指中国大陆以外的国家或地区运营商与用户之间发送和接收短信息的业务&#xff0c;是一种实现国际间沟通交流与信息触达的便捷方式&#xff0c;可广泛应用于出海游戏、跨境电商、在线社交、实体零…

「探索C语言内存:动态内存管理解析」

&#x1f320;先赞后看&#xff0c;不足指正!&#x1f320; &#x1f388;这将对我有很大的帮助&#xff01;&#x1f388; &#x1f4dd;所属专栏&#xff1a;C语言知识 &#x1f4dd;阿哇旭的主页&#xff1a;Awas-Home page 目录 引言 1. 静态内存 2. 动态内存 2.1 动态内…

比特币上最有价值的BRC-20,你了解吗?

BRC20 是比特币网络上发行同质化Token 的实验性格式标准&#xff0c;由domodata 于2023 年3 月8 日基于 Ordinal 协议创建。 类似于以太坊的 ERC20 标准&#xff0c;它规定了以太坊上发行 Token 的名称、发行量、转账等功能&#xff0c;所有基于以太坊开发的 Token 合约都遵守这…

计算机视觉——DiffYOLO 改进YOLO与扩散模型的抗噪声目标检测

概述 物体检测技术在图像处理和计算机视觉中发挥着重要作用。其中&#xff0c;YOLO 系列等型号因其高性能和高效率而备受关注。然而&#xff0c;在现实生活中&#xff0c;并非所有数据都是高质量的。在低质量数据集中&#xff0c;更难准确检测物体。为了解决这个问题&#xff…

axios 请求中断和请求重试

请求中断​ 请求已经发出去了&#xff0c;如何取消掉这个已经发出去的请求&#xff1f; 微信扫码体验一下 &#xff08;说不定哪天你就用得上&#xff09; 用途&#xff1a; 比如取消正在下载中的文件点击不同的下拉框选项&#xff0c;向服务器发送新请求但携带不同的参数&…

解决系统报错:此应用无法在你的电脑上运行

在开发过程中不知从何时起&#xff0c;使用电脑时过程中不断的都显示“此应用无法在你的电脑上运行”&#xff0c;让人非常恶心&#xff0c;一直以为是系统误操作了什么或误安了软件 百度的答案就是让你找到报错的软件用兼容模式运行。而我连报错的软件都不知道&#xff0c;让人…

盲人盲杖:科技革新,助力视障人士独立出行

在我们的社会中&#xff0c;盲人朋友们以其坚韧的精神风貌&#xff0c;生动诠释着生活的多样与可能。然而&#xff0c;当我们聚焦于他们的日常出行&#xff0c;那些普通人视为寻常的街道、路口&#xff0c;却成为他们必须面对的严峻挑战。如何切实提升盲人盲杖的功能&#xff0…

怎么检查3d模型里的垃圾文件---模大狮模型网

在处理3D模型时&#xff0c;经常会遇到一些不必要的垃圾文件&#xff0c;它们可能占据硬盘空间&#xff0c;增加文件大小&#xff0c;甚至影响模型的性能和质量。因此&#xff0c;及时检查和清理这些垃圾文件对于优化工作流程和提高效率非常重要。在本文中&#xff0c;我们将介…

利用Python进行大规模数据处理【第173篇—数据处理】

&#x1f47d;发现宝藏 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。【点击进入巨牛的人工智能学习网站】。 利用Python进行大规模数据处理&#xff1a;Hadoop与Spark的对比 随着数据量的不断增长&…

CSS中position属性总结

CSS中position属性的总结 如果我的文章看不懂&#xff0c;不要犹豫&#xff0c;请直接看阮一峰大佬写的文章 https://www.ruanyifeng.com/blog/2019/11/css-position.html 1 干嘛用的 用来定位HTML元素位置的&#xff0c;通过top、bottom、right、left定位元素 分别有这些值&a…

【DM8】ODBC

官网下载ODBC https://www.unixodbc.org/ 上传到linux系统中 /mnt下 [rootstudy ~]#cd /mnt [rootstudy mnt]# tar -zxvf unixODBC-2.3.12.tar.gz [rootstudy mnt]# cd unixODBC-2.3.12/ [rootstudy unixODBC-2.3.12]# ./configure 注意&#xff1a;若是报以上错 则是gcc未安…