Update 9


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {

private final static int parts = 1024 * 1024 * 10;

private final static String path = "C:" + File.separator;

public static void main(String[] args) throws Exception {
separate();
consolidate();
}

public static void separate() throws Exception {
byte[] temps = new byte[parts];
InputStream input = Main.class.getResourceAsStream("FAQ 8-13.rar");
int nRead;
int index = 0;
// 从输入流中读入字节流,然后写到文件中
while ((nRead = input.read(temps)) > 0) {
OutputStream output = new FileOutputStream(new File(path, "part" + index++ + ".zip"));
output.write(temps, 0, nRead);
output.close();
}
input.close();
System.out.println("SUCCESS");
}

public static void consolidate() throws Exception {
File files = new File(path);
String[] list;
list = files.list(new DirFilter());

int nRead;
byte[] temps = new byte[parts];
OutputStream output = new FileOutputStream(new File(path, "FAQ.rar"));
for (String name : list)
{
InputStream input = new FileInputStream(new File(path,name));
while ((nRead = input.read(temps)) > 0) {
output.write(temps, 0, nRead);
}
}
output.close();
System.out.println("SUCCESS");
}
}
// 名称过滤接口,accept返回true才通过过滤
class DirFilter implements FilenameFilter {
// dir - 被找到的文件所在的目录
// name - 文件的名称
public boolean accept(File dir, String name) {
boolean test = name.matches("part[0-9].*zip");
return test;
}
}

apt updateLinux 系统中用于软件包管理的重要命令,以下是关于它的使用方法及作用原理等方面的详细信息: ### 作用原理 apt update 命令的核心作用是通过访问配置的软件源(如 /etc/apt/sources.list 和 /etc/apt/sources.list.d/ 中的配置)同步最新的软件包列表信息到本地缓存。它会从服务器下载最新的软件包版本、依赖关系和可用性信息,更新本地软件包索引,但不会实际安装或升级任何软件。其运行依赖在 Ubuntu 上配置的软件源文件 /etc/apt/sources.list,本地软件仓库存放在 Ubuntu 上的 /var/lib/apt/lists/ 目录下 [^1][^3]。 ### 与 apt-get update 的区别 两者功能相同,但 apt update 是 apt-get 的改进版命令。在交互体验上,apt update 提供进度条和彩色高亮显示更新状态,更直观;而 apt-get update 仅输出简洁的日志信息,适合脚本调用。在附加功能方面,apt update 自动清理过期的软件包索引文件,减少冗余数据;apt-get update 需手动通过 apt-get clean 或 apt-get autoclean 清理缓存。在版本适配性上,apt 命令从 Ubuntu 16.04 开始被推荐使用,整合了 apt-get 和 apt-cache 的常用功能;apt-get 是传统命令,兼容性更强,适合需要稳定性的自动化脚本 [^1]。 ### 使用建议 日常操作中,优先使用 apt update,因其交互友好且集成优化功能;脚本编写时,使用 apt-get update,确保向后兼容性和日志格式的稳定性;与升级命令配合时,执行 update 后,通常需运行 apt upgrade 或 apt-get upgrade 来实际安装更新 [^1]。 ### 安全性 apt update 仅会更新本地的软件包索引文件(本地软件仓库),不会实际更新或升级任何软件,运行是安全的。它会保证本地软件仓库为最新版,所以在准备更新软件前先运行 apt update 是非常必要的 [^3]。 ### 示例代码 在终端中使用 apt update 命令的示例: ```bash sudo apt update ``` 使用 `sudo` 是因为更新软件包索引需要管理员权限。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值