scala 编写 hdfs 工具类

scala 编写 hdfs 工具类

scala 创建 删除 hdfs 文件或目录
scala 上传 下载 hdfs 文件
scala 读取 写入 hdfs 文件

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>cn.lihaozhe</groupId><artifactId>scala-code</artifactId><version>1.0.0</version><name>${project.artifactId}</name><properties><jdk.version>21</jdk.version><!-- 公共配置 --><maven.compiler.source>21</maven.compiler.source><maven.compiler.target>21</maven.compiler.target><maven.compiler.compilerVersion>21</maven.compiler.compilerVersion><maven.compiler.encoding>utf-8</maven.compiler.encoding><project.build.sourceEncoding>utf-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><maven.test.failure.ignore>true</maven.test.failure.ignore><maven.test.skip>true</maven.test.skip><commons-io.version>2.18.0</commons-io.version><commons-lang3.version>3.17.0</commons-lang3.version><druid.version>1.2.24</druid.version><fastjson.version>2.0.53</fastjson.version><fastjson2.version>2.0.53</fastjson2.version><gson.version>2.11.0</gson.version><hutool.version>5.8.34</hutool.version><jackson.version>2.18.2</jackson.version><junit.version>5.11.3</junit.version><lombok.version>1.18.36</lombok.version><mysql.version>9.1.0</mysql.version><scala.version>2.13.15</scala.version></properties><dependencies><dependency><groupId>org.scala-tools.testing</groupId><artifactId>specs_2.10</artifactId><version>1.6.9</version><scope>test</scope></dependency><dependency><groupId>org.scalatest</groupId><artifactId>scalatest_2.13</artifactId><version>3.2.19</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>${junit.version}</version><!-- 作用域 --><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-engine</artifactId><version>${junit.version}</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all --><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>${hutool.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>${commons-lang3.version}</version></dependency><!-- https://mvnrepository.com/artifact/commons-io/commons-io --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>${commons-io.version}</version></dependency><!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>${gson.version}</version></dependency><!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>${fastjson.version}</version></dependency><!--jackson--><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-core</artifactId><version>${jackson.version}</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-annotations</artifactId><version>${jackson.version}</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>${jackson.version}</version></dependency><dependency><groupId>com.fasterxml.jackson.datatype</groupId><artifactId>jackson-datatype-jsr310</artifactId><version>${jackson.version}</version></dependency><!--java 小工具--><dependency><groupId>com.github.binarywang</groupId><artifactId>java-testdata-generator</artifactId><version>1.1.2</version></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><version>${mysql.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>3.4.0</version></dependency></dependencies><build><finalName>${project.artifactId}</finalName><!--<outputDirectory>../package</outputDirectory>--><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.13.0</version><configuration><!-- 设置编译字符编码 --><encoding>UTF-8</encoding><!-- 设置编译jdk版本 --><source>${jdk.version}</source><target>${jdk.version}</target></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-clean-plugin</artifactId><version>3.4.0</version></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>3.3.1</version></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>3.4.2</version></plugin><!-- 编译级别 --><!-- 打包的时候跳过测试junit begin --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>3.5.2</version><configuration><skip>true</skip></configuration></plugin><!-- 该插件用于将Scala代码编译成class文件 --><plugin><groupId>net.alchim31.maven</groupId><artifactId>scala-maven-plugin</artifactId><version>4.9.2</version><configuration><scalaCompatVersion>${scala.version}</scalaCompatVersion><scalaVersion>${scala.version}</scalaVersion></configuration><executions><execution><id>scala-compile-first</id><phase>process-resources</phase><goals><goal>compile</goal></goals></execution><execution><goals><goal>testCompile</goal></goals></execution><execution><id>compile-scala</id><phase>compile</phase><goals><goal>add-source</goal><goal>compile</goal></goals></execution><execution><id>test-compile-scala</id><phase>test-compile</phase><goals><goal>add-source</goal><goal>testCompile</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>3.7.1</version><configuration><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin></plugins></build><repositories><repository><id>public</id><name>aliyun nexus</name><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases></repository></repositories><pluginRepositories><pluginRepository><id>public</id><name>aliyun nexus</name><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories>
</project>

HDFS工具类

package cn.lhz.util.hadoopimport org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path}
import org.apache.hadoop.hdfs.DistributedFileSystemimport java.io.IOException
import java.net.URI
import scala.io.{Codec, Source}/*** HDFS 工具类 scala版** @author 李昊哲* @version 1.0.0        */
object HdfsUtil {private val username = "root"/*** 获取 HDFS 伪分布式文件系统** @return 伪分布式文件系统* @throws IOException IOException*/@throws[IOException]def getFs(url: String): FileSystem = getFs(username, url)/*** 获取 HDFS 伪分布式文件系统** @return 伪分布式文件系统* @throws IOException IOException*/@throws[IOException]def getFs(username: String, url: String): FileSystem = {System.setProperty("HADOOP_USER_NAME", username)// 配置项val conf = new Configuration()// 设置 HDFS 地址conf.set("fs.defaultFS", "hdfs://" + url + ":8020")// 获取hdfs资源FileSystem.get(conf)}/*** 断开 伪分布式文件系统 HDFS 连接** @param fs HDFS 伪分布式文件系统* @throws IOException IOException*/@throws[IOException]def close(fs: FileSystem): Unit = {fs.close()}/*** 获取 HDFS 完全分布式文件系统** @return 完全分布式文件系统* @throws IOException IOException*/@throws[IOException]def getDfs: DistributedFileSystem = getDfs(username)/*** 获取 HDFS 完全分布式文件系统** @return 完全分布式文件系统* @throws IOException IOException*/@throws[IOException]def getDfs(username: String): DistributedFileSystem = {// 通过这种方式设置java客户端身份System.setProperty("HADOOP_USER_NAME", username)// 配置参数val conf = new Configuration()val dfs = new DistributedFileSystem()val nameService = conf.get("dfs.nameservices")val hdfsRPCUrl = "hdfs://" + nameService + ":" + 8020// 分布式文件系初始化dfs.initialize(URI.create(hdfsRPCUrl), conf)dfs}/*** 断开 HDFS 完全分布式文件系统 连接** @param dfs HDFS 完全分布式文件系统* @throws IOException IOException*/@throws[IOException]def close(dfs: DistributedFileSystem): Unit = {dfs.close()}/*** 创建目录 (完全分布式集群)** @param path 文件路径* @return 创建是否成功* @throws IOException IOException*/@throws[IOException]def mkdirs(path: String): Boolean = {val dfs = getDfsval result = dfs.mkdirs(new Path(path))dfs.close()result}/*** 创建目录 (完全分布式集群)** @param dfs  hdfs文件系统* @param path 文件路径* @return 创建是否成功* @throws IOException IOException*/@throws[IOException]def mkdirs(dfs: DistributedFileSystem, path: String): Boolean = dfs.mkdirs(new Path(path))/*** 创建目录 (伪分布式集群)** @param path 文件路径* @return 创建是否成功* @throws IOException IOException*/@throws[IOException]def mkdir(path: String): Boolean = {val fs = getFs(path)val result = mkdir(fs, path)fs.close()result}/*** 创建目录 (伪分布式集群)** @param fs   hdfs文件系统* @param path 文件路径* @return 创建是否成功* @throws IOException IOException*/@throws[IOException]def mkdir(fs: FileSystem, path: String): Boolean = fs.mkdirs(new Path(path))/*** 修改文件或目录名称 (完全分布式集群)** @param src 原文件路径* @param dst 新文件路径* @return 修改是否成功* @throws IOException IOException*/@throws[IOException]def rename(src: Path, dst: Path): Boolean = {val dfs = getDfsval result = dfs.rename(src, dst)dfs.close()result}/*** 修改文件或目录名称 (完全分布式集群)** @param dfs hdfs文件系统* @param src 原文件路径* @param dst 新文件路径* @return 修改是否成功* @throws IOException IOException*/@throws[IOException]def rename(dfs: DistributedFileSystem, src: Path, dst: Path): Boolean = dfs.rename(src, dst)/*** 修改文件或目录名称 (伪分布式集群)** @param fs  hdfs文件系统* @param src 原文件路径* @param dst 新文件路径* @return 修改是否成功* @throws IOException IOException*/@throws[IOException]def rename(fs: FileSystem, src: Path, dst: Path): Boolean = fs.rename(src, dst)/*** 删除文件或目录 (完全分布式集群)** @param path 文件路径* @return 删除是否成功* @throws IOException IOException*/@throws[IOException]def delete(path: String): Boolean = {val dfs = getDfsval result = delete(dfs, path)dfs.close()result}/*** 删除文件或目录 (完全分布式集群)** @param dfs  hdfs文件系统* @param path 文件路径* @return 删除是否成功* @throws IOException IOException*/@throws[IOException]def delete(dfs: DistributedFileSystem, path: String): Boolean = dfs.delete(new Path(path), true)/*** 删除文件或目录 (伪分布式集群)** @param fs   hdfs文件系统* @param path 文件路径* @return 删除是否成功* @throws IOException IOException*/@throws[IOException]def delete(fs: FileSystem, path: String): Boolean = fs.delete(new Path(path), true)/*** 文件上传 (完全分布式集群)** @param src 本地文件系统路径* @param dst hdfs文件系统路径* @throws IOException IOException*/@throws[IOException]def copyFromLocalFile(src: String, dst: String): Unit = {copyFromLocalFile(new Path(src), new Path(dst))}/*** 文件上传 (完全分布式集群)** @param src 本地文件系统路径* @param dst hdfs文件系统路径* @throws IOException IOException*/@throws[IOException]def copyFromLocalFile(src: Path, dst: Path): Unit = {val dfs = getDfsdfs.copyFromLocalFile(src, dst)dfs.close()}/*** 文件上传 (完全分布式集群)** @param dfs hdfs文件系统* @param src 本地文件系统路径* @param dst hdfs文件系统路径* @throws IOException IOException*/@throws[IOException]def copyFromLocalFile(dfs: DistributedFileSystem, src: Path, dst: Path): Unit = {dfs.copyFromLocalFile(src, dst)}/*** 文件下载 (完全分布式集群)** @param src hdfs文件系统路径* @param dst 本地文件系统路径* @throws IOException IOException*/@throws[IOException]def copyToLocalFile(src: String, dst: String): Unit = {copyToLocalFile(new Path(src), new Path(dst))}/*** 文件下载 (完全分布式集群)** @param src hdfs文件系统路径* @param dst 本地文件系统路径* @throws IOException IOException*/@throws[IOException]def copyToLocalFile(src: Path, dst: Path): Unit = {val dfs = getDfsdfs.copyToLocalFile(src, dst)dfs.close()}/*** 文件下载 (完全分布式集群)** @param dfs hdfs文件系统* @param src hdfs文件系统路径* @param dst 本地文件系统路径* @throws IOException IOException*/@throws[IOException]def copyToLocalFile(dfs: DistributedFileSystem, src: Path, dst: Path): Unit = {dfs.copyToLocalFile(src, dst)}/*** 文件上传 (伪分布式集群)** @param fs  hdfs文件系统* @param src 本地文件系统路径* @param dst hdfs文件系统路径* @throws IOException IOException*/@throws[IOException]def copyFromLocalFile(fs: FileSystem, src: Path, dst: Path): Unit = {fs.copyFromLocalFile(src, dst)}/*** 文件下载  (伪分布式集群)** @param fs  hdfs文件系统* @param src hdfs文件系统路径* @param dst 本地文件系统路径* @throws IOException IOException*/@throws[IOException]def copyToLocalFile(fs: FileSystem, src: Path, dst: Path): Unit = {fs.copyToLocalFile(src, dst)}/*** 获取文件列表  (完全分布式集群)** @param path hdfs文件系统路径* @return FileStatus[]* @throws IOException IOException*/@throws[IOException]def getList(path: String): Array[FileStatus] = {val dfs = getDfsval fileStatuses = dfs.listStatus(new Path(path))dfs.close()fileStatuses}/*** 获取文件列表  (完全分布式集群)** @param dfs  hdfs文件系统* @param path hdfs文件系统路径* @return FileStatus[]* @throws IOException IOException*/@throws[IOException]def getList(dfs: DistributedFileSystem, path: String): Array[FileStatus] = dfs.listStatus(new Path(path))/*** 获取文件列表 (伪分布式集群)** @param fs   hdfs文件系统* @param path hdfs文件系统路径* @return FileStatus[]* @throws IOException IOException*/@throws[IOException]def getList(fs: FileSystem, path: String): Array[FileStatus] = fs.listStatus(new Path(path))/*** 读取完全分布式文件** @param path hdfs文件系统路径* @return 文件内容* @throws IOException IOException*/@throws[IOException]def readFile(path: String): String = {val dfs = getDfs(path)val string = readFile(dfs, path)dfs.close()string}/*** 读取完全分布式文件** @param dfs  hdfs文件系统* @param path hdfs文件系统路径* @return 文件内容* @throws IOException IOException*/@throws[IOException]def readFile(dfs: DistributedFileSystem, path: String): String = {var content: String = ""val stream = dfs.open(new Path(path))val lines = Source.fromInputStream(stream)(Codec.UTF8).getLines()for (line <- lines) {content += s"$line\n"}if (content.isEmpty) {content} else {content.substring(0, content.lastIndexOf("\n"))}}/*** 写入完全分布式文件** @param path    hdfs文件系统路径* @param content 文件内容* @throws IOException IOException*/@throws[IOException]def writeFile(path: String, content: String): Unit = {val dfs = getDfswriteFile(dfs, path, content)dfs.close()}/*** 写入完全分布式文件** @param dfs     hdfs文件系统* @param path    hdfs文件系统路径* @param content 文件内容* @throws IOException IOException*/@throws[IOException]def writeFile(dfs: DistributedFileSystem, path: String, content: String): Unit = {val fsDataOutputStream = dfs.create(new Path(path), true)fsDataOutputStream.write(content.getBytes)fsDataOutputStream.close()}/*** 读取伪分布式文件** @param path hdfs文件系统路径* @return 文件内容* @throws IOException IOException*/@throws[IOException]def getString(path: String): String = {val fs = getFs(path)val string = getString(fs, path)fs.close()string}/*** 读取伪分布式文件** @param fs   hdfs文件系统路径* @param path hdfs文件系统路径* @return 文件内容* @throws IOException IOException*/@throws[IOException]def getString(fs: FileSystem, path: String) = {var content: String = ""val stream = fs.open(new Path(path))val lines = Source.fromInputStream(stream)(Codec.UTF8).getLines()for (line <- lines) {content += s"$line\n"}if (content.isEmpty) {content} else {content.substring(0, content.lastIndexOf("\n"))}}/*** 写入完全分布式文件** @param path    hdfs文件系统路径* @param content 文件内容* @throws IOException IOException*/@throws[IOException]def writeString(path: String, content: String): Unit = {val fs = getFs(path)writeString(fs, path, content)fs.close()}/*** 写入伪分布式文件** @param fs      hdfs文件系统* @param path    hdfs文件系统路径* @param content 文件内容* @throws IOException IOException*/@throws[IOException]def writeString(fs: FileSystem, path: String, content: String): Unit = {val fsDataOutputStream = fs.create(new Path(path), true)fsDataOutputStream.write(content.getBytes)fsDataOutputStream.close()}
}

测试 HDFS 工具类

package cn.lhz.util.hadoop/*** HDFS 工具类 scala版** @author 李昊哲* @version 1.0.0        */
object HdfsUtilTest {def main(args: Array[String]): Unit = {// hdfs 创建文件上传目录HdfsUtil.mkdirs("/scala/input")HdfsUtil.mkdirs("/scala/out")// 上传本地文件到 hdfsHdfsUtil copyFromLocalFile("course.txt", "/scala/input")// 读取 hdfs 文件内容val content = HdfsUtil.readFile("/scala/input/course.txt")// 控制台数据读取内容println(content)// 将从hdfs读取到的文件内容写入到hdfs文件当中HdfsUtil writeFile("/scala/out/course.txt", content)// 将写入到hdfs的文件下载到本地文件系统HdfsUtil copyToLocalFile("/scala/out/course.txt", "course.log")println("success")}
}

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

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

相关文章

从零用java实现 小红书 springboot vue uniapp (1)

前言 偶尔会用小红书发一些笔记 闲来无事 想自己实现一个小红书 正好可以学习一下 帖子 留言 im 好友 推送 等功能 下面我们就从零 开发一个小红书 后台依旧用我们的会员系统的脚手架 演示 http://120.26.95.195:8889/ 客户端我们使用uniapp 我们首先对主页进行一个分解 顶部我…

Cesium 按区域生成高度图

Cesium 按区域生成高度图 Cesium 按区域生成高度图 const cmd new CustomDrawCommand({vertexArray,shaderProgram,commandType: Compute,outputTexture: bufferColor,uniformMap,postExecute: () > {const url getImageByTexture(bufferAColor, gl);viewer.scene.primiti…

RESTful API设计原则与最佳实践

在当今的数字化时代&#xff0c;应用程序编程接口&#xff08;API&#xff09;已成为企业间数据交换、系统集成和业务扩展的关键工具。RESTful API作为一种基于HTTP协议的轻量级、无状态、可扩展的架构设计风格&#xff0c;在Web服务、移动应用、物联网等多个领域得到了广泛应用…

SpringMVC全局异常处理

一、Java中的异常 定义&#xff1a;异常是程序在运行过程中出现的一些错误&#xff0c;使用面向对象思想把这些错误用类来描述&#xff0c;那么一旦产生一个错误&#xff0c;即创建某一个错误的对象&#xff0c;这个对象就是异常对象。 类型&#xff1a; 声明异常&#xff1…

最小绝对偏差(Least Absolute Deviation, LAD)---子梯度法

最小绝对偏差&#xff08;Least Absolute Deviations&#xff0c;简称LAD&#xff09;是一种用于回归分析的统计方法&#xff0c;其目标是最小化残差的绝对值之和&#xff0c;而不是最小二乘法中的残差平方和。LAD回归特别适用于存在异常值的数据集&#xff0c;因为它对异常值不…

Linux - 进程等待和进程替换

进程等待 前面我们了解了如果父进程没有回收子进程, 那么当子进程接收后, 就会一直处于僵尸状态, 导致内存泄漏, 那么我们如何让父进程来回收子进程的资源. waitpid 我们可以通过 Linux 提供的系统调用函数 wait 系列函数来等待子进程死亡, 并回收资源. #include <sys/t…

mac下载安装jdk

背景 长时间不折腾mac全部忘记 特此记录 安装 1.下载jdk 根据需要下载对应的jdk 我直接 下载到/Applicatiions目录 https://www.oracle.com/java/technologies/downloads/#java8-mac 2.解压 cd /Applicatiions tar -zxvf jdk-8u431-macosx-x64.tar.gz 3.配置环境 …

【Java】—— 图书管理系统

基于往期学习的类和对象、继承、多态、抽象类和接口来完成一个控制台版本的 “图书管理系统” 在控制台界面中实现用户与程序交互 任务目标&#xff1a; 1、系统中能够表示多本图书的信息 2、提供两种用户&#xff08;普通用户&#xff0c;管理员&#xff09; 3、普通用户…

1-1.mysql2 之 mysql2 初识(mysql2 初识案例、初识案例挖掘)

一、mysql2 概述 mysql2 是一个用于 Node.js 的 MySQL 客户端库 mysql2 是 mysql 库的一个改进版本&#xff0c;提供了更好的性能和更多的功能 使用 mysql2 之前&#xff0c;需要先安装它 npm install mysql2 二、mysql2 初识案例 1、数据库准备 创建数据库 testdb CREAT…

[HDCTF 2023]LoginMaster

[HDCTF 2023]LoginMaster 知识点 quine注入 解题 用户名要为admin 查看robots.txt&#xff0c;查看源码 password是注入点 function checkSql($s) {if(preg_match("/regexp|between|in|flag||>|<|and|\||right|left|reverse|update|extractvalue|floor|subs…

springboot398研究生调研管理系统(论文+源码)_kaic

摘 要 互联网发展至今&#xff0c;无论是其理论还是技术都已经成熟&#xff0c;而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播&#xff0c;搭配信息管理工具可以很好地为人们提供服务。针对信息管理混乱&#xff0c;出错率高&#xff0c;信息安全性差&#…

OSCP - Proving Grounds - Zino

主要知识点 SMB知识python脚本提权 具体步骤 执行nmap Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-10 01:24 UTC Nmap scan report for 192.168.52.64 Host is up (0.00077s latency). Not shown: 65529 filtered tcp ports (no-response) PORT STATE SER…

JDK8新特性之Stream流03

收集Stream流中的结果 IntStream intStream = Stream.of(1, 2, 3, 4, 5).mapToInt(Integer::intValue); intStream.filter(n -> n > 3).forEach(System.out::println); intStream.filter(n -> n > 3).count; intStream.filter(n -> n > 3).reduce(0, Integer…

自制shell命令行解释器,深入理解Linux系统命令行实现原理

个人主页&#xff1a;敲上瘾-CSDN博客 个人专栏&#xff1a;Linux学习、游戏、数据结构、c语言基础、c学习、算法 目录 ​编辑 1.打印命令提示符 ​编辑 2.获取用户输入指令 3.重定向分析 4.命令行参数表与环境变量表 5.命令解析 6.命令执行 6.1.创建子进程 6.2.文件…

ADB常用各模块操作命令

目录 1. 基本设备信息获取 2. 设备连接与管理 3. 文件管理 4. 进程与应用管理 5. 日志与调试 6. 调试和性能 7. 设备操作 8.adb命令的应用场景 1. 基本设备信息获取 获取设备的系统版本&#xff0c;获取设备安卓版本号&#xff1a; adb shell getprop ro.build.version.…

Mac M1 安装数据库

1. Docker下载 由于Sqlserver和达梦等数据库&#xff0c;不支持M系列的芯片&#xff0c;所以我们通过docker安装 下载并安装docker: https://www.docker.com/get-started/ 安装完成后&#xff0c;打开docker 2. SQL Server 安装 2.1 安装 打开终端&#xff0c;执行命令 doc…

渗透测试实验环境搭建

下载虚拟机镜像 5个虚拟机镜像&#xff0c;其中Linux攻击机我选择用最新的kali Linux镜像&#xff0c;其余的均使用本书配套的镜像。 网络环境配置 VMware虚拟网络编辑器配置&#xff1a; 将VMnet1和VMnet8分别设置IP为192.168.10.0/24和10.10.10.0/24。 虚拟机镜像配置 攻击机…

Linux shell脚本(一)

监控内存和磁盘容量&#xff0c;小于给定值时报警 [rootlinux-lyz test1]# ./monitor.sh & [1] 23110 # 提取根分区剩余空间 disk_size$(df / | awk /\//{print $4})# 提取内存剩余空间 mem_size$(free | awk /Mem/{print $4}) while : do # 注意内存和磁盘提取空间大小都…

C# 中 Interface(接口)和 virtual(虚方法)

文章目录 前言一、Interface&#xff08;接口&#xff09;1. 什么是接口2. 接口的定义3. 实现接口4. 接口的作用 二、virtual&#xff08;虚方法&#xff09;1. 什么是虚方法2. 虚方法的定义3. 重写虚方法4. 虚方法的作用 三、Interface 和 virtual 的结合使用1. 接口中的虚方法…

JWT 在 SaaS 系统中的作用与分布式 SaaS 系统设计的最佳实践

在现代 SaaS&#xff08;软件即服务&#xff09; 系统中&#xff0c;随着服务规模的扩大和用户需求的多样化&#xff0c;如何高效、安全地进行用户身份验证、权限控制以及租户隔离&#xff0c;成为了系统架构中的核心问题之一。**JWT&#xff08;JSON Web Token&#xff09;**作…