【Java學習|黑馬筆記|Day21】IO流|緩沖流,轉換流,序列化流,反序列化流,打印流,解壓縮流,常用工具包相關用法及練習

標題【Java學習|黑馬筆記|Day20】

今天看的是黑馬程序員的《Java從入門到起飛》下部的95-118節,筆記包含IO流中的字節、字符緩沖流,轉換流,序列化流反序列化流,打印流,解壓縮流,常用工具包相關用法及練習


歡迎大家在評論區交流討論,一起學習共同進步🕵🏻?♀?

文章目錄

    • 標題【Java學習|黑馬筆記|Day20】
        • 10)上篇練習
          • 1.拷貝一個文件夾,考慮子文件夾
          • 2.文件加解密
          • 3.修改文件中的數據
        • 11)字節緩沖流
        • 11.1)字節緩沖流拷貝文件(一次讀一個字節)
        • 11.2)字節緩沖流拷貝文件(一次讀寫多個字節)
        • 11.3)底層原理
        • 12)字符緩沖流
        • 13)練習
          • 1.四種拷貝方式效率對比
          • 2.恢復出師表的順序
          • 3.控制軟件運行的次數
        • 14)轉換流
        • 14.1)練習
        • 15)序列化流
        • 16)反序列化流/對象操作輸入流
        • 17)(反)序列化流的細節
        • 18)練習
        • 19)打印流
        • 19.1)字節打印流
        • 19.2)字符打印流
        • 20.1)解壓縮流
        • 20.2)壓縮流
        • 21.1)常用工具包Commons-io
        • 21.2)常用工具包-Hutool

接上篇

10)上篇練習
1.拷貝一個文件夾,考慮子文件夾
public class T1 {public static void main(String[] args) throws IOException {//1.數據源File src = new File("D:\\a\\bbb");//2.目的地File dest = new File("D:\\a\\aaa");copydir(src,dest);}private static void copydir(File src, File dest) throws IOException {dest.mkdir();//如果dest不存在就創建一個File[] files = src.listFiles();for (File file : files) {if(file.isFile()){FileInputStream fis = new FileInputStream(file);FileOutputStream fos = new FileOutputStream(new File(dest,file.getName()));byte[] bytes = new byte[1024];int len;while((len = fis.read(bytes)) != -1){fos.write(bytes,0,len);}fos.close();fis.close();}else {copydir(file,new File(dest,file.getName()));}}}
}
2.文件加解密

加密:對原始文件的每一個字節數據進行更改,然后將更改后的數據存儲到新的文件中

解密:讀取加密之后的問價,按照加密的規則反向操作,編程原始文件

通過異或進行加解密

加密

//^異或 不同為true 一個數異或另一個數兩次結果是它本身
//1.創建對象關聯原始文件
FileInputStream fis = new FileInputStream("src\\1.jpg");
//2.創建對象關聯機密文件
FileOutputStream fos = new FileOutputStream("src\\ency.jpg");
//3.加密處理
int b;
while((b = fis.read()) != -1){fos.write(b ^ 2);
}
fos.close();
fis.close();

解密

//4.解密FileInputStream fis = new FileInputStream("src\\ency.jpg");
FileOutputStream fos = new FileOutputStream("src\\redu.jpg");
int b;
while((b =  fis.read()) != -1){fos.write(b ^ 2);
}
fos.close();
fis.close();
3.修改文件中的數據

排序文件中的數據

public static void main(String[] args) throws IOException {FileReader fr = new FileReader("src\\1.txt");StringBuilder sb = new StringBuilder();int ch;while ((ch = fr.read()) != -1) {sb.append((char)ch);}fr.close();String s = sb.toString();String[] arrStr = s.split("-");Arrays.sort(arrStr);System.out.println(Arrays.toString(arrStr));FileWriter fw = new FileWriter("src\\1.txt");for (int i = 0; i < arrStr.length; i++) {fw.write(arrStr[i]);if(i != arrStr.length-1){fw.write("-");}}fw.close();
}
11)字節緩沖流

在這里插入圖片描述

11.1)字節緩沖流拷貝文件(一次讀一個字節)

原理:底層自帶了長度為8192的緩沖區提高性能

方法名稱說明
public BufferedInputStream(InputStream is)把基本流包裝成高級流,提高讀取數據的性能
public BufferedOutputStream(OutputStream is)把基本流包裝成高級流,提高讀取數據的性能
public class T1 {public static void main(String[] args) throws IOException {BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src\\1.txt"));BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("src\\copy.txt"));int b;while((b = bis.read()) != -1){bos.write(b);}bos.close();bis.close();}
}
11.2)字節緩沖流拷貝文件(一次讀寫多個字節)
public class T1 {public static void main(String[] args) throws IOException {BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src\\1.txt"));BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("src\\copy.txt"));int len;byte[] bytes = new byte[1024];while((len = bis.read(bytes)) != -1){bos.write(bytes,0,len);}bos.close();bis.close();}
}
11.3)底層原理

在這里插入圖片描述

數據源通過基本流自動把數據加載到內存中的緩沖區,緩沖輸出流的緩沖區自動把數據傳給目的地,int b在兩緩沖區之間移動傳遞數據

為什么節省時間?

因為在內存當中操作速度非常快,int b來回傳遞的速度可以忽略不計

12)字符緩沖流
方法名稱說明
public BufferedReader(Reader r)把基本流包裝成高級流,提高讀取數據的性能
public BufferedWriter(Writer r)把基本流包裝成高級流,提高讀取數據的性能

字符緩沖流特有方法

字符緩沖輸入流特有方法說明
public String readLine()讀取一行數據,如果沒有數據可讀了會返回null
字符緩沖輸出流特有方法說明跨平臺的換行
public void newLine()讀取一行數據,如果沒有數據可讀了會返回null

字符緩沖輸出流

public class T1 {public static void main(String[] args) throws IOException {//創建對象BufferedReader br = new BufferedReader(new FileReader("src\\1.txt"));//讀取數據//readLine細節:在讀取時讀取一整行讀到回車換行結束,//              但是不會把回車換行讀到內存中String line;while((line = br.readLine()) != null){System.out.println(line);}//釋放資源br.close();}
}

字符緩沖輸入流

public class T1 {public static void main(String[] args) throws IOException {//創建對象BufferedWriter bw = new BufferedWriter(new FileWriter("src\\2.txt"));//讀取數據bw.write("123456789");bw.newLine();//釋放資源bw.close();}
}

總結

在這里插入圖片描述

13)練習
1.四種拷貝方式效率對比

字節基本流一次讀一個字節

字節基本流一次讀一個字節數組

字節緩沖流一次讀一個字節

字節緩沖流一個讀一個字節數組

public class T1 {public static void main(String[] args) throws IOException {long start = System.currentTimeMillis();//method1(); //method2();method3();//method4();long end = System.currentTimeMillis();System.out.println((end - start) / 1000.0 + "秒");}private static void method4() throws IOException {BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src\\1.txt"));BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("src\\2.txt"));int len;byte[] bytes = new byte[1024];while ((len = bis.read(bytes)) != -1) {bos.write(bytes);}bos.close();bis.close();}private static void method3() throws IOException {BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src\\1.txt"));BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("src\\2.txt"));int b;while ((b = bis.read()) != -1) {bos.write(b);}bos.close();bis.close();}private static void method2() throws IOException {FileInputStream fis = new FileInputStream("src\\1.txt");FileOutputStream fos = new FileOutputStream("src\\2.txt");int len;byte[] bytes = new byte[1024];while ((len = fis.read(bytes)) != -1) {fos.write(len);}fos.close();fis.close();}private static void method1() throws IOException {FileInputStream fis = new FileInputStream("src\\1.txt");FileOutputStream fos = new FileOutputStream("src\\2.txt");int b;while ((b = fis.read()) != -1) {fos.write(b);}fos.close();fis.close();}}
2.恢復出師表的順序
public class T1 {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new FileReader("D:\\BaiduNetdiskDownload\\csb.txt"));String line;ArrayList<String> list = new ArrayList<>();while((line = br.readLine()) != null){list.add(line);}br.close();Collections.sort(list, new Comparator<String>() {@Overridepublic int compare(String o1, String o2) {//獲取o1、o2序號return Integer.parseInt(o1.split("\\.")[0]) - Integer.parseInt(o2.split("\\.")[0]);}});BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\BaiduNetdiskDownload\\csbnew.txt"));for (String s : list) {bw.write(s);bw.newLine();}bw.close();}
}
3.控制軟件運行的次數

在這里插入圖片描述

public class T1 {public static void main(String[] args) throws IOException {//定義一個計數器保存在本地文件中,程序停止數據不會消失//1.讀取文件的數字count//原則:IO隨用隨建,不用就關閉BufferedReader br = new BufferedReader(new FileReader("src\\count.txt"));String line = br.readLine();br.close();int count = Integer.parseInt(line);count++;//又運行一次//2.判斷 > 3 不能運行if(count <= 3){System.out.println("歡迎使用,第" + count + "次免費");}else {System.out.println("只能免費使用三次,請注冊會員");}//bw創建在用的時候,如果創建到br下會清空文件使程序出錯BufferedWriter bw = new BufferedWriter(new FileWriter("src\\count.txt"));bw.write(count + "");//把數字轉換成字符bw.close();}
}
14)轉換流

字符流和字節流之間的橋梁

InputStreamReader字節流 轉換為 字符流,并可以指定字符編碼(如 UTF-8、GBK 等)來正確解析字節。

OutputStreamWriter字符流寫入到字節流中,并可以指定字符編碼(如 UTF-8、GBK 等)。
在這里插入圖片描述

eg:利用轉換流按照指定字符編碼讀取

public class T1 {public static void main(String[] args) throws IOException {//法一(已淘汰)InputStreamReader isr = new InputStreamReader(new FileInputStream("D:\\a\\1.txt"),"GBK");int ch;while((ch = isr.read()) != -1){System.out.print((char)ch);}isr.close();//法二:用FileReaderFileReader fr = new FileReader("D:\\a\\1.txt", Charset.forName("GBK"));int ch1;while((ch1 = fr.read()) != -1){System.out.print((char)ch1);}fr.close();}
}
14.1)練習

利用字節流讀取文件中的數據,每次讀一行

public class T1 {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\a\\1.txt")));String str = br.readLine();System.out.println(str);br.close();}
}
15)序列化流

在這里插入圖片描述

序列化流/對象操作輸出流:可以把Java中的對象寫到本地文件中

構造方法說明
public ObjectOutputStream(OubtputStream out)把基本流包裝成高級流
成員方法說明
public final void writeObject(Object obj)把對象序列化寫出到文件中
public class T1 {public static void main(String[] args) throws IOException {Student stu = new Student("zs",23);//創建序列化流對象ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("src\\1.txt"));//細節:使用對象輸出流保存到文件時會出現NotSerializableException異常//     解決方案:需要讓Javabean類實現Serializable接口//寫出數據oos.writeObject(stu);//關閉資源oos.close();}
}
//Serializable接口里沒有抽象方法,是標記型接口
//一旦實現了找個接口表示當前的Student類可以被序列化
public class Student implements Serializable {private String name;private int age;//......}
16)反序列化流/對象操作輸入流

可以把序列化到本地文件中的對象讀取到程序中來

構造方法說明
public ObjectInputStream(InputStream out)把基本流升級為高級流
成員方法說明
public Object readObject()把序列化到本地的對象讀取到程序中
public class T1 {public static void main(String[] args) throws IOException, ClassNotFoundException {//創建對象ObjectInputStream ois = new ObjectInputStream(new FileInputStream("src//1.txt"));//讀取數據Student o = (Student)ois.readObject();//返回值類型是Object 可以強轉成Student//打印對象System.out.println(o);//釋放資源ois.close();}
}
17)(反)序列化流的細節

創建一個對象的序列化流后,又修改對象的成員變量會報錯,報錯原因:文件中的版本號跟Javabean的版本號不匹配

處理方法:固定版本號

public static Student implements Serializable{private static final long 版本號 = 1L;private Stirng name;private int age;private String address;
}

在這里插入圖片描述

18)練習

讀寫多個對象,個數不確定

//序列化流
public class T1 {public static void main(String[] args) throws IOException, ClassNotFoundException {Student s1 = new Student("zs",23);Student s2 = new Student("ls",24);Student s3 = new Student("ww",25);ArrayList<Student> list = new ArrayList<>();list.add(s1);list.add(s2);list.add(s3);ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("src\\1.txt"));oos.writeObject(list);oos.close();}
}
//反序列化流
public class T2 {public static void main(String[] args) throws IOException, ClassNotFoundException {ObjectInputStream ois = new ObjectInputStream(new FileInputStream("src\\1.txt"));ArrayList<Student> list = (ArrayList<Student>) ois.readObject();for (Student student : list) {System.out.println(student);}ois.close();}
}
19)打印流

分類PrintStream字節打印流,PrintWriter字符打印流

特點

  1. 打印流只操作文件目的地,不操作數據源
  2. 特有的寫出方法,數據原樣寫出 eg:打印97 文件中97
19.1)字節打印流
構造方法說明
public PrintStream(OutputStream/File/String)灌流字節輸出流/文件/文件路徑
public PrintStream(String fileName,Charset charset)指定字符編碼
public PrintStream(OutputStream out,bollean autoFlush)自動刷新
public PrintStream(OutputStream out,boolean autoFlush,String encoding)指定字符編碼且自動刷新

字節流底層沒有緩沖區,開不開自動刷新都一樣

成員方法說明
public void write(int b)將指定的字節寫出
public void println(Xxx xx)特有:打印任意數據,自動刷新,自動換行
public void print(Xxx xx)特有:打印任意數據,不換行
public void printf(String format,Object…args)特有:帶有占位符的打印語句,不換行
PrintStream ps = new PrintStream(new FileOutputStream("src\\1.txt"),true,Charset.forName("UTF-8"));ps.println(97);//寫出+自動刷新+自動換行
ps.print(true);
ps.printf(" %s 1 %s","a","b");ps.close();
//占位符
//%n 換行
//%c 大寫
//%b boolean類型的
//%d 小數的占位符
19.2)字符打印流
構造方法說明
public PrintWrite(Write/File/String)關聯字節輸出流/文件/文件路徑
public PrintWrite(String fileName,Charset charset)指定字符編碼
public PrintWrite(Write w,boolean autoFlush)自動刷新
public PrintWrite(OutputStream out,bollean autoFlush,Charset charset)指定字符編碼且自動刷新

字符流底層有緩沖區,相應自動刷新需要開啟

成員方法說明
public void write(int b)將指定的字節寫出
public void println(Xxx xx)特有:打印任意數據,自動刷新,自動換行
public void print(Xxx xx)特有:打印任意數據,不換行
public void printf(String format,Object…args)特有:帶有占位符的打印語句,不換行
PrintWriter pw = new PrintWriter(new FileWriter("src\\1.txt"),true);
pw.println("a");
pw.print("b");
pw.printf(" %s 1 %s","a","b");pw.close();

打印流的應用場景

    //獲取打印流的對象,此打印流在虛擬機,不能關閉,在系統中唯一啟動時由虛擬機創建默認指向控制臺//特殊的打印流,系統中的標準輸出流PrintStream ps = System.out;//調用打印輸出流的println寫出數據自動換行自動刷新ps.println("123");ps.close();System.out.println("asd");//關閉后sout也不能打印了
20.1)解壓縮流

解壓本質:把每一個ZipEntry按照層級拷貝到本地另一個文件夾中

public class T1 {public static void main(String[] args) throws IOException {//1.創建一個File表示要解壓的壓縮包File src = new File("D:\\a\\1.zip");//2.創建一個File表示是解壓的目的地File dest = new File("D:\\a");//調用方法unzip(src, dest);}public static void unzip(File src,File dest) throws IOException {//創建一個解壓縮流用來讀取壓縮包中的數據ZipInputStream zip = new ZipInputStream(new FileInputStream(src));//獲取壓縮包里每一個zipEntry對象ZipEntry entry;//getNextEntry可以獲取壓縮包里的所有文件文件夾while((entry = zip.getNextEntry()) != null) {System.out.println(entry);//如果是文件夾需要再dest創建一個同樣的文件夾//如果是文件拷貝到dest中if(entry.isDirectory()) {File file = new File(dest, entry.toString());file.mkdirs();//創建多層目錄}else {FileOutputStream fos = new FileOutputStream(new File(dest, entry.toString()));int b;while((b=zip.read()) != -1) {fos.write(b);}fos.close();//表示壓縮包中的一個文件處理完畢了}}zip.close();}
}
20.2)壓縮流

壓縮單個文件

public class T1 {public static void main(String[] args) throws IOException {//1.創建File對象表示要壓縮的文件File src = new File("D:\\a\\1.txt");//2.創建File對象表示壓縮包的位置File dest = new File("D:\\a\\");//調用方法toZip(src,dest);}public static void toZip(File src, File dest) throws IOException {//1.創建壓縮流關聯壓縮包ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(new File(dest,"a.zip")));//2.把ZipEntry對象表示壓縮包里每一個對象ZipEntry entry = new ZipEntry("a.txt");//3.把對象放到壓縮包里zos.putNextEntry(entry);//4.把src文件中的數據寫到壓縮包中FileInputStream fis = new FileInputStream(src);int b;while((b = fis.read()) != -1) {zos.write(b);}fis.close();zos.closeEntry();zos.close();}
}

壓縮整個文件夾

public class T1 {public static void main(String[] args) throws IOException {//1.創建File對象表示要壓縮的文件File src = new File("D:\\a\\aaa");//2.創建File對象表示元素包的父級目錄File destParent = src.getParentFile();//3.創建File對象表示壓縮包的位置File dest = new File( destParent,src.getName() +".zip");//4.創建壓縮流關聯壓縮包ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(dest));//5.獲取src里面的每一個文件,變成ZipEntry對象放到壓縮包中toZip(src,zos,src.getName());zos.close();}public static void toZip(File src, ZipOutputStream zos,String name) throws IOException {//1.進入src文件夾File[]  files = src.listFiles();for (File file : files) {if(file.isFile()){//變成ZipEntry對象放到壓縮包ZipEntry entry = new ZipEntry(name + "\\" + file.getName());zos.putNextEntry(entry);//讀取文件中的數據寫到壓縮包FileInputStream fis = new FileInputStream(file);int b;while((b = fis.read()) != -1){zos.write(b);}fis.close();zos.closeEntry();}else {toZip(file,zos,name + "\\"+file.getName());}}}
}
21.1)常用工具包Commons-io

是一組IO操作的開源工具包

作業:提高IO流的開發效率

使用步驟

  1. 在項目中創建一個文件夾:lib
  2. jar包復制粘貼到lib文件夾
  3. 右鍵點擊jar包,選擇Add as Library -> 點擊OK
  4. 在類中導包使用

在這里插入圖片描述

在這里插入圖片描述

eg

File src = new File("src\\1.txt");
File dest = new File("src\\2.txt");
FileUtils.copyFile(src,dest);
21.2)常用工具包-Hutool

在這里插入圖片描述

(筆記內容主要基于黑馬程序員的課程講解,旨在加深理解和便于日后復習)
在這里插入圖片描述

希望這篇筆記能對大家的學習有所幫助,有啥不對的地方歡迎大佬們在評論區

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/90351.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/90351.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/90351.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

API網關原理與使用場景詳解

一、API網關核心原理 1. 架構定位 #mermaid-svg-hpDCWfqoiLcVvTzq {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-hpDCWfqoiLcVvTzq .error-icon{fill:#552222;}#mermaid-svg-hpDCWfqoiLcVvTzq .error-text{fill:#5…

OSPF路由協議——上

OSPF路由協議 RIP的不足 以跳數評估的路由并非最優路徑如果RTA選擇s0/0傳輸&#xff0c;傳輸需時會大大縮短為3s 最大跳數為16跳&#xff0c;導致網絡尺度小RIP協議限制網絡直徑不能超過16跳&#xff0c;并且16跳為不可達。 收斂速度慢 RIP 定期路由更新 更新計時器&#xff1a…

(LeetCode 面試經典 150 題) 219. 存在重復元素 II (哈希表)

題目&#xff1a;219. 存在重復元素 II 思路&#xff1a;哈希表&#xff0c;時間復雜度0(n)。 哈希表記錄每個數最新的下標&#xff0c;遇到符合要求的返回true即可。 C版本&#xff1a; class Solution { public:bool containsNearbyDuplicate(vector<int>& nums,…

Cookies 詳解及其與 Session 的協同工作

Cookies 詳解及其與 Session 的協同工作 一、Cookies 的本質與作用 1. 什么是 Cookies&#xff1f; Cookies 是由服務器發送到用戶瀏覽器并存儲在本地的小型文本文件。核心特性&#xff1a; 存儲位置&#xff1a;客戶端瀏覽器數據形式&#xff1a;鍵值對字符串&#xff08;最大…

DeepSeek Janus Pro本地部署與調用

step1、Janus模型下載與項目部署 創建文件夾autodl-tmp https://github.com/deepseek-ai/Janus?tabreadme-ov-file# janusflow 查看是否安裝了git&#xff0c;沒有安裝的話安裝一下&#xff0c;或者是直接github上下載&#xff0c;上傳到服務器&#xff0c;然后解壓 git --v…

【Elasticsearch】BM25的discount_overlaps參數

discount_overlaps 是 Elasticsearch/Lucene 相似度模型&#xff08;Similarity&#xff09;里的一個布爾參數&#xff0c;用來決定&#xff1a;> 在計算文檔長度歸一化因子&#xff08;norm&#xff09;時&#xff0c;是否忽略“重疊 token”&#xff08;即位置增量 positi…

Linux | LVS--Linux虛擬服務器知識點(上)

一. 集群與分布式1.1 系統性能擴展方式當系統面臨性能瓶頸時&#xff0c;通常有以下兩種主流擴展思路&#xff1a;Scale Up&#xff08;向上擴展&#xff09;&#xff1a;通過增強單臺服務器的硬件配置來提升性能&#xff0c;這種方式簡單直接&#xff0c;但受限于硬件物理極限…

【Linux-云原生-筆記】keepalived相關

一、概念Keepalived 是一個用 C 語言編寫的、輕量級的高可用性和負載均衡解決方案軟件。 它的主要目標是在基于 Linux 的系統上提供簡單而強大的故障轉移功能&#xff0c;并可以結合 Linux Virtual Server 提供負載均衡。1、Keepalived 主要提供兩大功能&#xff1a;高可用性&a…

計算機網絡:概述層---計算機網絡的組成和功能

&#x1f310; 計算機網絡基礎全景梳理&#xff1a;組成、功能與核心機制 &#x1f4c5; 更新時間&#xff1a;2025年7月21日 &#x1f3f7;? 標簽&#xff1a;計算機網絡 | 網絡組成 | 分布式 | 負載均衡 | 資源共享 | 網絡可靠性 | 計網基礎 文章目錄前言一、組成1.從組成部…

Linux中scp命令傳輸文件到服務器報錯

上傳本地文件到Linux服務器使用scp命令報錯解決辦法使用scp命令報錯 Could not resolve hostname e: Name or service not known 解決辦法 不使用登錄服務器的工具傳輸&#xff0c;打開本地cmd&#xff0c;使用scp命令傳輸即可。 scp E:\dcm-admin.jar root127.0.0.1:/

歷史數據分析——國藥現代

醫藥板塊走勢分析: 從月線級別來看 2008年11月到2021年2月,月線上走出了兩個震蕩中樞的月線級別2085-20349的上漲段; 2021年2月到2024年9月,月線上走出了20349-6702的下跌段; 目前月線級別放巨量,總體還在震蕩區間內,后續還有震蕩和上漲的概率。 從周線級別來看 從…

#Linux內存管理# 在一個播放系統中同時打開幾十個不同的高清視頻文件,發現播放有些卡頓,打開視頻文件是用mmap函數,請簡單分析原因。

在播放系統中同時使用mmap打開幾十個高清視頻文件出現卡頓&#xff0c;主要原因如下&#xff1a;1. 內存映射&#xff08;mmap&#xff09;的缺頁中斷開銷按需加載機制&#xff1a;mmap將文件映射到虛擬地址空間&#xff0c;但實際數據加載由“缺頁中斷&#xff08;Page Fault&…

AI黑科技:GAN如何生成逼真人臉

GAN的概念 GAN(Generative Adversarial Network,生成對抗網絡)是一種深度學習模型,由生成器(Generator)和判別器(Discriminator)兩部分組成。生成器負責生成 synthetic data(如假圖像、文本等),判別器則試圖區分生成數據和真實數據。兩者通過對抗訓練不斷優化,最終…

FireFox一些設置

firefox后臺打開新的鏈接&#xff0c;例如中鍵打開一個鏈接 地址欄輸入about:config 找到下面三項&#xff0c;全部設為true browser.tabs.loadInBackground browser.tabs.loadDivertedInBackground browser.tabs.loadBookmarksInBackground 參考&#xff1a;FireFox/chrome…

【黑馬SpringCloud微服務開發與實戰】(六)分布式事務

1. 什么是分布式事務下單失敗&#xff0c;購物車還被清理了。不符合一致性。2. seata的架構和原理3. 部署TC服務docker network ls docker inspect mysql mysql 在hm-net下&#xff0c;這里我的ncaos不是跟著視頻配的&#xff0c;因此需要。 docker network connect hm-net nac…

【力扣】第15題:三數之和

原文鏈接&#xff1a;15. 三數之和 - 力扣&#xff08;LeetCode&#xff09; 思路解析 雙指針&#xff1a; &#xff08;1&#xff09;頭尾指針對應值相加如果大于目標值(target)&#xff0c;那么只能尾指針-1&#xff1b;如果小于target&#xff0c;那么只能頭指針1。 &#x…

Linux PCI總線子系統

The Linux Kernel Archives Linux PCI總線子系統 — The Linux Kernel documentation

LeetCode熱題100--24. 兩兩交換鏈表中的節點--中等

1. 題目 給你一個鏈表&#xff0c;兩兩交換其中相鄰的節點&#xff0c;并返回交換后鏈表的頭節點。你必須在不修改節點內部的值的情況下完成本題&#xff08;即&#xff0c;只能進行節點交換&#xff09;。 示例 1&#xff1a; 輸入&#xff1a;head [1,2,3,4] 輸出&#x…

京東視覺算法面試30問全景精解

京東視覺算法面試30問全景精解 ——零售智能 供應鏈創新 工業落地:京東視覺算法面試核心考點全覽 前言 京東作為中國領先的零售科技企業,在智能物流、供應鏈管理、智能倉儲、商品識別、工業質檢等領域持續推動視覺AI的創新與大規模落地。京東視覺算法崗位面試不僅關注候…

【設計模式】觀察者模式 (發布-訂閱模式,模型-視圖模式,源-監聽器模式,從屬者模式)

觀察者模式&#xff08;Observer Pattern&#xff09;詳解一、觀察者模式簡介 觀察者模式&#xff08;Observer Pattern&#xff09; 是一種 行為型設計模式&#xff08;對象行為型模式&#xff09;&#xff0c;它定義了一種一對多的依賴關系&#xff0c;讓多個觀察者對象同時監…