io基础入门

news2024/10/5 13:08:29

压缩的封装

参考:https://blog.csdn.net/qq_29897369/article/details/120407125?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-120407125-blog-120163063.235v38pc_relevant_sort_base3&spm=1001.2101.3001.4242.1&utm_relevant_index=3

Resource

Java的标准java.net.URL类和各种URL前缀的标准处理程序还不足以满足对所有低级资源的访问;Resource接口在Spring和Spring中被大量使用
用实用程序类:资源抽象不能取代功能。它尽可能地包装它。例如,UrlResource包装一个URL,并使用包装的URL来完成它的工作

Spring包括几个内置的资源实现:

UrlResource

UrlResource包装了一个java.net.URL,可用于访问通常可以通过URL访问的任何对象,如文件、HTTPS目标、FTP目标等
路径字符串包含一个众所周知的(对属性编辑器来说)前缀(例如classpath:),它将为该前缀创建一个适当的专门化资源;
如果它不识别前缀,则假定该字符串是标准URL字符串并创建UrlResource;

ClassPathResource

该类表示应该从类路径获得的资源
JavaBeans PropertyEditor识别字符串路径上的特殊前缀classpath:,并在这种情况下创建ClassPathResource;

/**
getPath: 返回此资源的路径:a.txt
getAbsolutePath: /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/test-classes/a.txt
**/
@Test
public void demo3(){
    ClassPathResource classPathResource = new ClassPathResource("a.txt");
    System.out.println(classPathResource.getPath());
    try {
        System.out.println(classPathResource.getFile().getAbsolutePath());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

test-classes和classes的区别:一个是@test资源resources和一个是项目资源resources
注意: 如果test-classes和classes资源不存在需要,maven重新install

FileSystemResource

这是java.io.File句柄的Resource实现
支持文件解析和URL解析;

PathResource

是一个纯粹的基于java.nio.path.Path的FileSystemResource替代品

ServletContextResource

这是ServletContext资源的Resource实现,用于解释相关web应用程序根目录中的相对路径。

InputStreamResource

InputStreamResource是给定InputStream的资源实现

ByteArrayResource

这是给定字节数组的Resource实现。它为给定的字节数组创建一个ByteArrayInputStream。

ResourceLoader

所有应用程序上下文实现ResourceLoader接口。因此,所有应用程序上下文都可以用于获取Resource实例。
会为每个上下文返回适当的对象。(ServletContextResource,FileSystemResource)
可以通过指定任何标准java.net.URL前缀来强制使用UrlResource。使用文件和https前缀的示例如下:

Resource template = ctx.getResource("file:///some/resource/path/myTemplate.txt");
Resource template = ctx.getResource("https://myhost.com/resource/path/myTemplate.txt");

classpath:
classpath:com/myapp/config.xml
file:
file:///data/config.xml
https:
https://myserver/logo.png
/data/config.xml:
取决于底层的ApplicationContext。

ResourcePatternResolver

Ant-style路径模式解析为资源对象

PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
        Resource[] resources = resourcePatternResolver.getResources(mapperLocations);
        sqlSessionFactoryBean.setMapperLocations(resources);
@Test
public void demo4() {
    PathMatchingResourcePatternResolver resource = new PathMatchingResourcePatternResolver();
    Resource resource1 = resource.getResource("classpath:a.txt");
    try {
        System.out.println(resource1.getFile().getAbsolutePath());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    try {
        Resource[] resources = resource.getResources("*.txt");
        for (Resource resource2 : resources) {
            System.out.println(resource2.getFile().getAbsolutePath());
//                        /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/test-classes/a.txt
//                        /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/test-classes/b.txt
//                        /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/test-classes/c.txt
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

classpath*:

classpath*:/config/beans.xml

您还可以依赖于ResourceLoader的自动装配,作为实现ResourceLoaderAware接口的替代方案。

资源路径没有前缀,根据应用程序上下文的确切类型;
如果需要强制使用特定的资源类型,可以使用前缀

@Component
public class MyBean {

    private final Resource template;

    public MyBean(@Value("${template.path}") Resource template) {
        this.template = template;
    }

    // ...
}

Ant-style Patterns

/WEB-INF/-context.xml
com/mycompany/**/applicationContext.xml
file:C:/some/path/
-context.xml
classpath:com/mycompany/**/applicationContext.xml

通配符类路径依赖于底层ClassLoader的getResources()方法

相对路径相对于当前工作目录,而绝对路径相对于文件系统的根目录

hutool加载资源

import cn.hutool.setting.dialect.Props;


Props props = new Props("demo.properties");
System.out.println(props.get("name"));

类加载器加载资源

// 路径 /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/src/main/java
package com.wx.utils.Demo
public class Demo {
	public static void main(String[] args) {
	    System.out.println(Demo.class.getClassLoader().getResource("").getPath());
	    // /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/classes/
	    System.out.println(Demo.class.getClassLoader().getResource("application.yml").getPath());
	    // /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/classes/application.yml
	    System.out.println(Demo.class.getClassLoader().getResource("com/wx/WxApplication.class").getPath());
	    // /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/classes/com/wx/WxApplication.class
	
	    System.out.println(Demo.class.getResource("").getPath());
	    // /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/classes/com/wx/utils/
	    System.out.println(Demo.class.getResource("Demo.class").getPath());
	   // /Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/target/classes/com/wx/utils/Demo.class
	
	    InputStream is = Demo.class.getClassLoader().getResourceAsStream("demo.properties");
	
	    Properties properties = new Properties();
	    try {
	        properties.load(is);
	        System.out.println(properties.get("name"));
	    } catch (IOException e) {
	        throw new RuntimeException(e);
	    }
	}
}

demo.properties

name=zjy

在这里插入图片描述

File类

参考: https://www.ydlclass.com/doc21xnv/java/first/javase/12%E3%80%81IO%E6%B5%81/#_6%E3%80%81file%E7%B1%BB%E7%9A%84%E8%8E%B7%E5%8F%96%E5%8A%9F%E8%83%BD%E5%92%8C%E4%BF%AE%E6%94%B9%E5%90%8D%E5%AD%97%E5%8A%9F%E8%83%BD
​ 在 Java 中,File 类是 java.io 包中唯一代表磁盘文件本身的对象。File 类定义了一些与平台无关的方法来操作文件,File类主要用来获取或处理与磁盘文件相关的信息,像文件名、 文件路径、访问权限和修改日期等,还可以浏览子目录层次结构。   File 类表示处理文件和文件系统的相关信息。也就是说,File 类不具有从文件读取信息和向文件写入信息的功能,它仅描述文件本身的属性。
File(String pathname)
File(File parent,String child)
File file = new File(“D:\code\a.txt”);
File file = new File(“D:\code”);
File child = new File(file,“a.txt”);

File类创建和删除功能

boolean createNewFile() 指定路径不存在该文件时创建文件,返回true 否则false
boolean mkdir() 当指定的单击文件夹不存在时创建文件夹并返回true 否则false
boolean mkdirs() 当指定的多级文件夹在某一级文件夹不存在时,创建多级文件夹并返回true 否则false
boolean delete() 删除文件或者删除单级文件夹

File类的判断功能

boolean exists() 判断指定路径的文件或文件夹是否为空
boolean isAbsolute() 判断当前路径是否是绝对路径
boolean isDirectory() 判断当前的目录是否存在
boolean isFile() 判断当前的目录是否是一个文件
boolean isHidden() 判断当前路径是否是一隐藏文件

File类的获取功能和修改名字功能

File getAbsoluteFile() 获取文件的绝对路径,返回File对象
String getAbsolutePath() 获取文件的绝对路径,返回路径的字符串
String getParent() 获取当前路径的父级路径,以字符串形式返回该父级路径
String getName() 获取文件或文件夹的名称
String getPath() 获取File对象中封装的路径
long lastModified() 以毫秒值返回最后修改时间
long length() 返回文件的字节数
boolean renameTo(File dest) 将当前File对象所指向的路径修改为指定File所指向的路径

文件夹列表操作

返回值 方法 描述
String list() 得到这个文件夹下的所有文件,返回路径数组
String[] list(FilenameFilter filter) 通过过滤器过滤文件,过滤通过文件名过滤,返回路径数组
File[] listFiles() 得到这个文件夹下的所有文件,返回文件数组
File[] listFiles(FileFilter filter) 通过过滤器过滤文件,过滤通过文件过滤,返回文件数组
File[] listFiles(FilenameFilter filter) 通过过滤器过滤文件,过滤通过文件名过滤,返回文件数组

public class FileTest {
    @Test
    public void demo(){
        getImageName(new File("/Users/yyyyjinying/Downloads"));
    }

    private void getImageName(File file) {
        if (file.isDirectory()) {
            File[] files = file.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    if (dir.isDirectory() || dir.getName().endsWith(".png")) {
                        return true;

                    }
                    return false;
                }
            });

            for (File file1 : files) {
                getImageName(file1);
            }

        } else if(file.getName().endsWith(".png")) {
            System.out.println(file.getName());
        }
    }
}

IO流

输入流和输出流:是否写入程序内存;
字节流和字符流:是一个字节一个字节的读取或写入

分类字节输入流字节输出流字符输入流字符输出流
抽象基类InputStreamOutputStreamReaderWriter
访问文件FileInputStreamFileOutputStreamFileReaderFileWriter
访问数组ByteArrayInputStreamByteArrayOutputStreamCharArrayReaderCharArrayWriter
访问字符串StringReaderStringWriter
缓冲流(处理)BufferedInputStreamBufferedOutputStreamBufferedReaderBufferedWriter
操作对象ObjectInputStreamObjectOutputStream

一个流读完了就没有了,就不能在读了

字节流通过InputStreamReader转化为字符流

// 字节流通过InputStreamReader转化为字符流,通过BufferedReader处理流
 BufferedReader reader = new BufferedReader(new InputStreamReader(tarArchiveInputStream));
String line;
while ((line = reader.readLine()) != null) {
    list.add(line);
}

字符流通过ByteArrayInputStream转化为字节流

List<String> list = Arrays.asList("Hello", "world!");
StringBuilder builder = new StringBuilder();
list.forEach(item -> {
   builder.append(item);
   builder.append("\n");
});
String str = builder.toString();
byteArrayInputStream = new ByteArrayInputStream(str.getBytes());
bufferedInputStream = new BufferedInputStream(byteArrayInputStream);

集合字符串输入文件中

List<String> list = Arrays.asList("Hello", "world!");

String str = builder.toString();
File tempFile = File.createTempFile("demo8", ".txt");
// 第一种
StringBuilder builder = new StringBuilder();
list.forEach(item -> {
   builder.append(item);
   builder.append("\n");
});
try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile))) {
    writer.write(str);
}
// 第二种 
FileUtil.writeLines(list, tempFile, Charset.forName("UTF-8"));

字节流和字符流的输入输出

public class IOUtilsTest {
    @Test
    public void demo() {
        try (
                InputStream inputStream = new FileInputStream(new File("/Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/src/test/resources/a.txt"));
                FileOutputStream fileOutputStream = new FileOutputStream(new File("/Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/src/test/resources/b.txt"), true)
        ) {
            byte[] buf = new byte[1024];
            int len;
            while ((len = inputStream.read(buf)) != -1) {
//               write(b, off, len)的一般契约是数组b中的一些字节按顺序写入输出流;元素b[off]是写入的第一个字节,
//               b[off+len-1]是该操作写入的最后一个字节。
//               OutputStream的write方法在每个要写入的字节上调用一个参数的write方法
                fileOutputStream.write(buf, 0, len);
            }


        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void demo2(){
        File fileInput = new File("/Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/src/test/resources/a.txt");
        File fileOutput = new File("/Users/yyyyjinying/demo-file/git/backend/wx-project/wx-official-project/src/test/resources/c.txt");
        FileReader fileReader = null;
        FileWriter fileWriter = null;
        try {
            fileReader = new FileReader(fileInput);
            fileWriter = new FileWriter(fileOutput);
            char[] buf = new char[1024];
            int len;
            while((len = fileReader.read(buf)) != -1){
                fileWriter.write(buf, 0, len);
            }

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                fileReader.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            try {
                fileWriter.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }


}

IOUtils.closeQuietly

可以简化io关闭的代码,

import org.apache.tomcat.util.http.fileupload.IOUtils;
import java.io.StringReader;
import java.io.StringWriter;
 try {
 
 } catch (IOException e) { 

 } finally {
       if (in != null) {
          try {
              in.close();
          } catch (IOException e) {
             
          }
       }
       if (out != null) {
          try {
              out.close();
          } catch (IOException e) {
             
          }
       }
 }       

 try {
 
 } catch (IOException e) { 

 } finally {
       IOUtils.closeQuietly(in);
       IOUtils.closeQuietly(out);
 }       
String content = "字符串";
StringReader reader = new StringReader(content);
StringWriter sw = new StringWriter();
try {
    //渲染模板 模板名没有取默认值
    String templateName = map.getOrDefault("templateName", "generator").toString();
    Template template = new Template(templateName, reader, null, "utf-8");
    template.process(map, sw);
} catch (Exception e) {
    e.printStackTrace();
    throw new RenException("渲染模板失败,请检查模板语法", e);
}

content = sw.toString();

IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(sw);
return content;

序列化和反序列化

序列化:将对象写入到IO流中,说的简单一点就是将内存模型的对象变成字节数字,可以进行存储和传输;
反序列化:从IO流中恢复对象,将存储在磁盘或者从网络接收的数据恢复成对象模型;
使用场景:所有可在网络上传输的对象都必须是可序列化的,否则会出错;所有需要保存到磁盘的Java对象都必须是可序列化的。
序列化版本号:我们知道,反序列化必须拥有class文件,但随着项目的升级,class文件也会升级,序列化怎么保证升级前后的兼容性呢?​ Java序列化提供了一个``private static final long serialVersionUID` 的序列化版本号,只要版本号相同,即使更改了序列化属性,对象也可以正确被反序列化回来。序列化版本号可自由指定,如果不指定,JVM会根据类信息自己计算一个版本号,这样随着class的升级、代码的修改等因素无法正确反序列化;不指定版本号另一个明显隐患是,不利于jvm间的移植,可能class文件没有更改,但不同jvm可能计算的规则不一样,这样也会导致无法反序列化。
所有需要网络传输的对象都需要实现序列化接口。
对象的类名、实例变量(包括基本类型,数组,对其他对象的引用)都会被序列化;方法、类变量、transient实例变量都不会被序列化。如果想让某个变量不被序列化,使用transient修饰。序列化对象的引用类型成员变量,也必须是可序列化的,否则,会报错。反序列化时必须有序列化对象的class文件。同一对象序列化多次,只有第一次序列化为二进制流,以后都只是保存序列化编号,不会重复序列化。建议所有可序列化的类加上serialVersionUID 版本号,方便项目升级。

/**
     * user对象通过字节流实现深拷贝
     * @throws CloneNotSupportedException
     */
    @Test
    public void deepClone() throws IOException, ClassNotFoundException {
        User user = new User("aa", "bb");
        user.setDog(new Dog("dog"));


        // 写出缓存字节数组
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(byteArrayOutputStream);
        out.writeObject(user);

        byte[] bytes = byteArrayOutputStream.toByteArray();

        // 将缓存字节数组写入程序对象
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        ObjectInputStream in = new ObjectInputStream(byteArrayInputStream);

        User user1 = (User) in.readObject();

// 关闭资源
        byteArrayInputStream.close();
        in.close();
        out.close();
        byteArrayOutputStream.close();




        user.setName("xiugai");
        user.getDog().setName("xigou");


        System.out.println(user);
        System.out.println(user1);
    }

    @Test
    public void qianClone() throws CloneNotSupportedException {
        User user = new User("aa", "bb");
        user.setDog(new Dog("dog"));


        User user1 = (User) user.clone();

        user.setName("xiugai");
        user.getDog().setName("xigou");


        System.out.println(user);
        System.out.println(user1);
    }

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

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

相关文章

05-建造者模式-C语言实现

UML类图&#xff1a; 代码实现&#xff1a; #include <stdio.h> #include <stdlib.h>// 产品类 typedef struct {char* part1;char* part2;char* part3; } Product;// 抽象建造者类 typedef struct {void (*buildPart1)(void*, const char*);void (*buildPart2)(v…

【广州华锐视点】广东3D展厅开发服务找广州华锐视点,打造未来展览新体验!

随着科技的不断发展&#xff0c;人们对于信息获取和传播的方式也在不断创新。传统的实体展览馆在空间、时间、地域等方面存在诸多限制&#xff0c;而3D数字展厅则为我们提供了一个全新的解决方案。广州华锐互动致力于为客户提供专业的3D数字展厅定制开发服务&#xff0c;让您的…

4个Pycharm高效插件

大家好&#xff0c;Pycharm是Python最受欢迎的集成开发环境之一&#xff0c;它具有良好的代码助手、漂亮的主题和快捷方式&#xff0c;使编写代码变得简单快捷。话虽如此&#xff0c;开发者仍可以通过使用一些插件来提高在Pycharm中编写Python代码的效率和乐趣&#xff0c;在市…

PID控制

在PID控制中&#xff0c;输出通常是一个控制量&#xff0c;而不是直接的PWM占空比。输出的具体含义可以根据具体的系统和应用而变化。在这段代码中&#xff0c;PID控制器的输出是 output_calc。 而 CCR_duty 是控制施肥系统的PWM占空比&#xff0c;这是通过PID控制的输出和曲线…

华为云之快速部署FTP站点

华为云之快速部署FTP站点 一、本次实践介绍1.1 实践环境简介1.2 本次实践目的 二、vsftpd介绍2.1 vsftpd简介2.2 vsftpd特点 三、环境准备工作3.1 预置实验环境3.2 查看预置环境信息3.3 登录华为云3.4 查看弹性云服务器状态3.5 查看弹性公网IP地址3.6 ssh登录弹性云服务器3.6 查…

System.out.println隐藏字符串

昨天开发的时候遇到一个坑&#xff0c;这个坑几乎浪费了我一整天时间&#xff0c;我甚至现在都不知道其原因。 开发环境 macOS Ventura 13.4 IntelliJ IDEA 2023.1.2 现象 我用java的各种httpclient获取网络上的一个文本文件&#xff0c;获取的文本文件的内容使用System.ou…

Python 网络爬虫(一):HTML 基础知识

《Python入门核心技术》专栏总目录・点这里 文章目录 1. 什么是 HTML2. HTML 的特点3. HTML 的标签和属性4. HTML 的结构4.1 文档类型声明4.2 根元素4.3 头部部分4.4 主体部分4.5 表格标签4.6 区块4.7 嵌套和层次结构4.8 表单4.9 注释 5. HTML 交互事件 大家好&#xff0c;我是…

Postman Post请求上传文件

Postman Post请求上传文件 一、选择post请求方式&#xff0c;输入请求地址 二、填写Headers Key&#xff1a;Content-Type Value&#xff1a;multipart/form-data [{"key":"Content-Type","value":"multipart/form-data","de…

CSS 滚动捕获 scroll-padding

scroll-padding 非滚动捕获容器滚动捕获容器语法兼容性 CSS 滚动捕获 scroll-padding 设置元素的滚动内边距, 就像 padding 所做的那样. 但并不影响布局. 非滚动捕获容器 我们先来看看不影响布局到底是什么意思. 我们平时会见到左侧是内容, 右侧是内容导航的页面, 比如下图 这…

uniApp打包的手机app如果用户没开启通知权限、引导用户开启

封装一个setPermissions.js文件 /*** 如果用户没开启通知权限、引导用户开启 */ export function setPermissions() {// #ifdef APP-PLUS if (plus.os.name Android) {var main plus.android.runtimeMainActivity();var pkName main.getPackageName();var uid main.getApp…

Python项目管理利器poetry我愿称之为神!

MongoDB是一种流行的NoSQL数据库&#xff0c;它以灵活的文档结构存储数据。MongoDB 提供了可用于 32 位和 64 位系统的预编译二进制包&#xff0c;你可以从MongoDB官网下载安装&#xff0c;MongoDB 预编译二进制包下载地址&#xff1a; https://www.mongodb.com/try/download/…

5.C转python

新始: 13.列表可被改变(数据),元组不可被改变(数据),二者皆与C中的数组的大致相同 14.创建列表方法: 1.一个[ ]就是一个空的列表 2.使用list函数来创建列表 如: 15.可以在[ ]内部指定列表的初始值,打印方法: 如: 16.在python中,在同一个列表中,可以放不同类型的变量(也可…

centos7 yum安装nginx

1.安装源 yum install epel-release 2.安装 (-y 的意思是自动yes) yum install nginx -y 3.查找安装到哪里了 whereis nginx 一般都是在 /etc/nginx下面 4.常用命令 检查配置文件是否正确 nginx -t 启动 systemctl start nginx 查看状态 systemctl status nginx 设置开…

为XiunoBBS4.0开启redis缓存且支持密码验证

修改模块文件1 xiunoPHP/cache_redis.class.php: <?phpclass cache_redis {public $conf array();public $link NULL;public $cachepre ;public $errno 0;public $errstr ;public function __construct($conf array()) {if(!extension_loaded(Redis)) {return $thi…

大数据技术之Oozie

大数据技术之Oozie 第1章 Oozie简介 Oozie英文翻译为&#xff1a;驯象人。一个基于工作流引擎的开源框架&#xff0c;由Cloudera公司贡献给Apache&#xff0c;提供对Hadoop MapReduce、Pig Jobs的任务调度与协调。Oozie需要部署到Java Servlet容器中运行。主要用于定时调度任…

【技术分享】RK356X Android11 以太网共享4G网络

本文基于IDO-SBC3566-V1B Android11系统实现开机后以太网自动共享4G网络功能。 IDO-SBC3566基于瑞芯微RK3566研发的一款高性能低功耗的智能主板&#xff0c;采用四核A55,主频高达1.8GHz&#xff0c;专为个人移动互联网设备和AIOT设备而设计&#xff0c;内置了多种功能强大的嵌…

docker踩坑记录:docker容器创建doris容器间无法通讯问题

背景&#xff1a; 开发大数据平台&#xff0c;使用doris作为数据仓储&#xff0c;使用docker做集群部署&#xff0c;先进行开发环境搭建&#xff0c;环境为BE1;FE1&#xff0c;原来使用官方例子&#xff0c;但是官方例子是创建了一个bridge使用172.20.80.0/24通讯&#xff0c;…

设计模式---第四篇

系列文章目录 文章目录 系列文章目录前言一、说说策略模式在我们生活的场景?二、知道责任链模式吗?三、了解过适配器模式么?前言 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站,这篇文章男女通用,看懂了就去分享给…

【集合篇】Java集合概述

Java 集合概述 集合与容器 容器&#xff08;Container&#xff09;是一个更广泛的术语&#xff0c;用于表示可以容纳、组织和管理其他对象的对象。它是一个更高层次的概念&#xff0c;包括集合&#xff08;Collection&#xff09;在内。集合&#xff08;Collection&#xff0…

Linux下为可执行文件添加图标

Ubuntu 18.04上使用Qt5.14.2创建一个简单的Qt Widgets项目test&#xff0c;添加2个Push Button按钮&#xff0c;点击分别获取github和csdn地址&#xff0c;在mainwindow.cpp中添加的代码如下: #include "mainwindow.h" #include "ui_mainwindow.h" #inclu…