广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Java压缩文件操作详解
  • 258
分享到

Java压缩文件操作详解

Java 压缩文件夹Java压缩文件操作Java压缩文件 2022-11-13 14:11:42 258人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

目录一、题目描述-压缩文本文件1、题目2、解题思路3、代码详解二、题目描述-压缩文件解压到指定文件夹1、题目2、解题思路3、代码详解三、题目描述-压缩所有子文件夹1、题目2、解题思路

一、题目描述-压缩文本文件

1、题目

题目:使用文本压缩技术,可以节约磁盘空间,还便于管理。

实现:做一个压缩指定文件夹内的所有文本文件的工具

2、解题思路

创建一个类:ZipTextFileFrame

使用ZipTextFileFrame继承JFrame构建窗体

压缩文件主要用到压缩输出流ZipOutputStream

以zip文件格式写入文件实现输出流过滤器。

每一个文件在压缩过程中会被存到zipEntry

使用putNextEntry()方法,增加zipEntry

压缩文件会放在选择文件夹的同级目录,并以java.zip命名。

3、代码详解

package com.xiaoxuzhu;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.jscrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;


public class ZipTextFileFrame extends JFrame {

    
    private static final long serialVersionUID = -8885017327239429018L;
    private JPanel contentPane;
    private JTextField chooseTextField;
    private JTable table;
    private File[] textFiles;

    
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    ZipTextFileFrame frame = new ZipTextFileFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    
    public ZipTextFileFrame() {
        setTitle("压缩所有文本文件");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new BorderLayout(0, 0));

        JPanel choosePanel = new JPanel();
        contentPane.add(choosePanel, BorderLayout.NORTH);

        chooseTextField = new JTextField();
        choosePanel.add(chooseTextField);
        chooseTextField.setColumns(18);

        JButton chooseButton = new JButton("选择文件夹");
        chooseButton.addActionListener(new ActionListener() {
            public void actionPerfORMed(ActionEvent arg0) {
                do_chooseButton_actionPerformed(arg0);
            }
        });
        choosePanel.add(chooseButton);

        JPanel buttonPanel = new JPanel();
        contentPane.add(buttonPanel, BorderLayout.SOUTH);

        JButton zipButton = new JButton("开始压缩");
        zipButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_zipButton_actionPerformed(arg0);
            }
        });
        buttonPanel.add(zipButton);

        JScrollPane scrollPane = new JScrollPane();
        contentPane.add(scrollPane, BorderLayout.CENTER);

        table = new JTable();
        scrollPane.setViewportView(table);
    }

    protected void do_chooseButton_actionPerformed(ActionEvent arg0) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fileChooser.setMultiSelectionEnabled(false);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {
            File selectFile = fileChooser.getSelectedFile();
            chooseTextField.setText(selectFile.getAbsolutePath());
            textFiles = selectFile.listFiles(new FileFilter() {

                @Override
                public boolean accept(File file) {
                    if (file.getPath().endsWith(".txt")) {
                        return true;
                    }
                    return false;
                }
            });
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.setColumnIdentifiers(new Object[] { "序号", "文件名" });
            for (int i = 0; i < textFiles.length; i++) {
                model.addRow(new Object[] { i + 1, textFiles[i].getName() });
            }
            table.setModel(model);
        }
    }

    protected void do_zipButton_actionPerformed(ActionEvent arg0) {
        if (chooseTextField.getText().length() == 0) {
            JOptionPane.showMessageDialog(this, "请选择要压缩的文件夹", "", JOptionPane.WARNING_MESSAGE);
            return;
        }
        String zipFilePath = new File(chooseTextField.getText()).getParent();
        try {
            zipFile(textFiles, new File(zipFilePath + File.separator + "java.zip"));
            JOptionPane.showMessageDialog(this, "完成压缩");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void zipFile(File[] files, File targetZipFile) throws IOException {
        // 利用给定的targetZipFile对象创建文件输出流对象
        FileOutputStream fos = new FileOutputStream(targetZipFile);
        ZipOutputStream zos = new ZipOutputStream(fos);// 利用文件输出流创建压缩输出流
        byte[] buffer = new byte[1024];// 创建写入压缩文件的数组
        for (File file : files) {// 遍历全部文件
            ZipEntry entry = new ZipEntry(file.getName());// 利用每个文件的名字创建ZipEntry对象
            FileInputStream fis = new FileInputStream(file);// 利用每个文件创建文件输入流对象
            zos.putNextEntry(entry);// 在压缩文件中添加一个ZipEntry对象
            int read = 0;
            while ((read = fis.read(buffer)) != -1) {
                zos.write(buffer, 0, read);// 将输入写入到压缩文件
            }
            zos.closeEntry();// 关闭ZipEntry
            fis.close();// 释放资源
        }
        zos.close();
        fos.close();
    }

}

压缩成功:

查看压缩结果:

二、题目描述-压缩文件解压到指定文件夹

1、题目

题目:实现一个压缩文件解压到指定文件夹的工具

2、解题思路

创建一个类:UnZipTextFileFrame

先获取一个zip格式的压缩文件

再指定要解压缩存放的文件夹

使用JAVA自带的压缩工具包来实现解压缩功能

利用用户选择的ZIP文件创建ZipFile对象

遍历ZipFile对象的枚举变量, 获得ZipEntry对象

获得的ZipEntry对象的输入流,将输入流写入到本地文件,这样就达到了解压缩功能。

3、代码详解

package com.xiaoxuzhu;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;


public class UnZipTextFileFrame extends JFrame {

    
    private static final long serialVersionUID = -7525621255251725313L;
    private JPanel contentPane;
    private JTextField sourceTextField;
    private JTable table;
    private File zipFile;
    private JTextField targetTextField;
    private File targetFile;

    
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    UnZipTextFileFrame frame = new UnZipTextFileFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    
    public UnZipTextFileFrame() {
        setTitle("压缩文件解压到指定文件夹");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new BorderLayout(0, 0));

        JPanel choosePanel = new JPanel();
        contentPane.add(choosePanel, BorderLayout.NORTH);

        sourceTextField = new JTextField();
        choosePanel.add(sourceTextField);
        sourceTextField.setColumns(10);

        JButton sourceButton = new JButton("Zip文件");
        sourceButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_sourceButton_actionPerformed(arg0);
            }
        });
        choosePanel.add(sourceButton);

        targetTextField = new JTextField();
        choosePanel.add(targetTextField);
        targetTextField.setColumns(10);

        JButton targetButton = new JButton("解压到");
        targetButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_targetButton_actionPerformed(arg0);
            }
        });
        choosePanel.add(targetButton);

        JPanel buttonPanel = new JPanel();
        contentPane.add(buttonPanel, BorderLayout.SOUTH);

        JButton unzipButton = new JButton("开始解压缩");
        unzipButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_unzipButton_actionPerformed(arg0);
            }
        });
        buttonPanel.add(unzipButton);

        JScrollPane scrollPane = new JScrollPane();
        contentPane.add(scrollPane, BorderLayout.CENTER);

        table = new JTable();
        scrollPane.setViewportView(table);
    }

    protected void do_sourceButton_actionPerformed(ActionEvent arg0) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileFilter(new FileNameExtensionFilter("文本文件", "zip"));
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {
            zipFile = fileChooser.getSelectedFile();
            sourceTextField.setText(zipFile.getAbsolutePath());
        }
    }

    protected void do_targetButton_actionPerformed(ActionEvent arg0) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {
            targetFile = fileChooser.getSelectedFile();
            targetTextField.setText(targetFile.getAbsolutePath());
        }
    }

    @SuppressWarnings("rawtypes")
    protected void do_unzipButton_actionPerformed(ActionEvent arg0) {
        DefaultTableModel model = (DefaultTableModel) table.getModel();// 获得表格模型
        model.setColumnIdentifiers(new Object[] { "序号", "文件名" });// 设置表头
        int id = 1;// 声明序号变量
        ZipFile zf = null;
        try {
            zf = new ZipFile(zipFile);// 利用用户选择的ZIP文件创建ZipFile对象
            Enumeration e = zf.entries();// 创建枚举变量
            while (e.hasMoreElements()) {// 遍历枚举变量
                ZipEntry entry = (ZipEntry) e.nextElement();// 获得ZipEntry对象
                if (!entry.getName().endsWith(".txt")) {// 如果不是文本文件就不进行解压缩
                    continue;
                }
                // 利用用户选择的文件夹和ZipEntry对象名称创建解压后的文件
                File currentFile = new File(targetFile + File.separator + entry.getName());
                FileOutputStream out = new FileOutputStream(currentFile);
                InputStream in = zf.getInputStream(entry);// 利用获得的ZipEntry对象的输入流
                int buffer = 0;
                while ((buffer = in.read()) != -1) {// 将输入流写入到本地文件
                    out.write(buffer);
                }
                model.addRow(new Object[] { id++, currentFile.getName() });// 增加一行表格数据
                in.close();// 释放资源
                out.close();
            }
            table.setModel(model);// 更新表格
            JOptionPane.showMessageDialog(this, "解压缩完成");// 提示用户解压缩完成
        } catch (ZipException e) {// 捕获异常
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (zf != null) {
                try {
                    zf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}

解压成功:

三、题目描述-压缩所有子文件夹

1、题目

题目:做一个压缩所有子文件夹的工具

2、解题思路

创建一个类:ZipDirectoryFrame

使用ZipDirectoryFrame继承JFrame构建窗体

压缩包含子文件夹的文件夹方案和压缩全是文件的文件夹类似,区别在如果找出包含子文件夹的文件夹所有文件。

并且构造ZipEntry时,不要有重名的情况。

可以用要压缩文件夹中所有文件的相对路径来做区分。

ZipEntry entry = new ZipEntry(string.substring(base.length() + 1, string.length()));// 利用要压缩文件的相对路径创建ZipEntry对象

压缩文件会放在选择文件夹的同级目录,并以选择文件夹的文件夹名+“.zip”命名。

3、代码详解

package com.xiaoxuzhu;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;


public class ZipDirectoryFrame extends JFrame {

    
    private static final long serialVersionUID = -138842864977841594L;
    private JPanel contentPane;
    private JTextField chooseTextField;
    private JTable table;
    private File selectFile;

    
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    ZipDirectoryFrame frame = new ZipDirectoryFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    
    public ZipDirectoryFrame() {
        setTitle("压缩所有子文件夹");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new BorderLayout(0, 0));

        JPanel choosePanel = new JPanel();
        contentPane.add(choosePanel, BorderLayout.NORTH);

        chooseTextField = new JTextField();
        choosePanel.add(chooseTextField);
        chooseTextField.setColumns(18);

        JButton chooseButton = new JButton("选择文件夹");
        chooseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_chooseButton_actionPerformed(arg0);
            }
        });
        choosePanel.add(chooseButton);

        JPanel buttonPanel = new JPanel();
        contentPane.add(buttonPanel, BorderLayout.SOUTH);

        JButton zipButton = new JButton("开始压缩");
        zipButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                do_zipButton_actionPerformed(arg0);
            }
        });
        buttonPanel.add(zipButton);

        JScrollPane scrollPane = new JScrollPane();
        contentPane.add(scrollPane, BorderLayout.CENTER);

        table = new JTable();
        scrollPane.setViewportView(table);
    }

    protected void do_chooseButton_actionPerformed(ActionEvent arg0) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fileChooser.setMultiSelectionEnabled(false);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {
            selectFile = fileChooser.getSelectedFile();
            chooseTextField.setText(selectFile.getAbsolutePath());
        }
    }

    protected void do_zipButton_actionPerformed(ActionEvent arg0) {

        List<String> path = new ArrayList<String>();
        getPath(selectFile, path);
        DefaultTableModel model = (DefaultTableModel) table.getModel();
        model.setColumnIdentifiers(new Object[] { "序号", "文件" });
        int id = 1;
        for (String string : path) {
            model.addRow(new Object[] { id++, new File(string).getName() });
        }
        String targetZipFilePath = selectFile.getParent() +File.separator + selectFile.getName() + ".zip";
        try {
            zipFile(path, new File(targetZipFilePath), selectFile.getAbsolutePath());
            JOptionPane.showMessageDialog(this, "文件夹压缩成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void getPath(File rootFile, List<String> path) {
        File[] files = rootFile.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                getPath(file, path);
            } else {
                path.add(file.getAbsolutePath());
            }
        }
    }

    private void zipFile(List<String> path, File targetZipFile, String base) throws IOException {
        // 根据给定的targetZipFile创建文件输出流对象
        FileOutputStream fos = new FileOutputStream(targetZipFile);
        ZipOutputStream zos = new ZipOutputStream(fos);// 利用文件输出流对象创建Zip输出流对象
        byte[] buffer = new byte[1024];
        for (String string : path) {// 遍历所有要压缩文件的路径
            File currentFile = new File(string);
            ZipEntry entry = new ZipEntry(string.substring(base.length() + 1, string.length()));// 利用要压缩文件的相对路径创建ZipEntry对象
            FileInputStream fis = new FileInputStream(currentFile);
            zos.putNextEntry(entry);
            int read = 0;
            while ((read = fis.read(buffer)) != -1) {// 将数据写入到Zip输出流中
                zos.write(buffer, 0, read);
            }
            zos.closeEntry();// 关闭ZipEntry对象
            fis.close();
        }
        zos.close();// 释放资源
        fos.close();
    }

}

选择文件夹

要压缩的文件夹是上面两个例子的文件夹

压缩成功:

压缩结果:

到此这篇关于Java压缩文件操作详解的文章就介绍到这了,更多相关Java压缩文件内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Java压缩文件操作详解

本文链接: https://www.lsjlt.com/news/172296.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Java压缩文件操作详解
    目录一、题目描述-压缩文本文件1、题目2、解题思路3、代码详解二、题目描述-压缩文件解压到指定文件夹1、题目2、解题思路3、代码详解三、题目描述-压缩所有子文件夹1、题目2、解题思路...
    99+
    2022-11-13
    Java 压缩文件夹 Java压缩文件操作 Java压缩文件
  • Java压缩与解压缩ZIP文件
    文章目录 前言Java解压缩文件压缩和解压缩ZIP文件检验应用总结 前言 在现代计算机上,数据传输和存储越来越依赖于文件压缩技术。当我们需要发送大量数据时,压缩文件可以大大减少传输时间...
    99+
    2023-09-11
    java zip 压缩文件 解压缩文件 ZipOutputStream
  • 【Java 基础篇】Java Zip压缩:简化文件和文件夹的压缩操作
    文章目录 导言一、Zip压缩简介二、压缩文件1. 创建压缩文件2. 压缩多个文件3. 压缩文件夹 三、解压缩文件1、解压缩文件 总结 导言 在Java开发中,经常会遇到需要对文件和文件夹进行压缩和解压缩的需求。J...
    99+
    2023-08-17
    java python php
  • Python 解压缩文件详解
    zipfile模块及相关方法介绍: 1 压缩 1.1 创建zipfile对象 zipfile.ZipFile(file, mode='r', compression=0, allowZip64=True, compresslevel=Non...
    99+
    2023-01-31
    解压缩 详解 文件
  • 详解Linux解压缩文件
    gzip 压缩:gzip -v 文件(夹)        eg: gzip -v b.log    ----> b...
    99+
    2022-06-04
    linux 解压缩文件
  • 【linux】tar指令压缩解压缩文件夹、文件命令详解
    1. tar常用命令: 压缩当前目录下文件夹/文件test到test.tar.gz: tar -zcvf test.tar.gz test 解压缩当前目录下的file.tar.gz到file: tar...
    99+
    2023-08-31
    linux 服务器 运维 压缩tar
  • Java实现文件压缩为zip和解压zip压缩包
    目录压缩成.zip解压.zip压缩成.zip 代码如下: public static void toZip(String srcDir, OutputStream out) th...
    99+
    2022-11-13
  • java如何解压与压缩文件夹
    这篇文章将为大家详细讲解有关java如何解压与压缩文件夹,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。注意:JDK7支持设置编码设置编码格式 zipFile,zipInputStream,zipOutpu...
    99+
    2023-05-31
    java
  • golang中tar压缩和解压文件详情
    目录1、压缩并输出tar.gz文档 2、tar解压缩 查看官方文档,官方自带的演示: // 官方演示 package main import ( "archive/t...
    99+
    2022-11-12
  • java使用ant.jar解压缩文件
    要使用Ant.jar解压缩文件,你需要编写一个Ant构建文件,并使用Ant命令行工具来执行该构建文件。以下是一个示例构建文件的内容:...
    99+
    2023-09-23
    java
  • java工具类 - 实现文件压缩zip及解压缩
    对hutool工具类进行的封装 依赖 cn.hutool hutool-all 5.8.15 ...
    99+
    2023-10-28
    java
  • Linux平台中用Python脚本操作实现文件压缩与解压缩
    Linux平台中利用Python脚本进行文件压缩与解压缩是一种十分便捷和高效的方法。在本文中,我们将讨论如何使用Python编写脚本来实现文件的压缩和解压缩,并提供具体的代码示例。一、文件压缩文件压缩是将一个或多个文件打包并压缩成一个单独的...
    99+
    2023-10-22
    Python Linux 文件压缩
  • Java的zip文件压缩与解压:ZipInputStream,ZipOutputStream
    目录 文件压缩 ZipOutputStream文件解压:ZipInputStream 文件压缩 ZipOutputStream    用ZipOutputStream来压缩一个文件夹时,要搭配ZipEntry来使用。ZipEnt...
    99+
    2023-08-16
    java ZipInputStream ZipOutputStream zip
  • Java如何实现文件压缩为zip和解压zip压缩包
    本篇内容介绍了“Java如何实现文件压缩为zip和解压zip压缩包”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!压缩成.zip代码如下:pu...
    99+
    2023-07-02
  • PHP Linux脚本操作实例:实现文件压缩与解压
    在Linux系统中,文件的压缩与解压是经常使用的操作。PHP作为一种强大的服务器端编程语言,在Linux环境中同样可以使用PHP脚本来完成文件压缩与解压的操作。本文将介绍如何使用PHP脚本来实现文件的压缩与解压,并提供具体的代码示例。文件压...
    99+
    2023-10-21
    Linux PHP 文件压缩
  • 利用Java怎么对文件进行压缩与解压缩
    今天就跟大家聊聊有关利用Java怎么对文件进行压缩与解压缩,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。用java压缩/解压文件: import java.io.*; im...
    99+
    2023-05-31
    java ava
  • linux压缩文件和文件解压缩命令介绍
    目录常见压缩格式:gz .bz2 .xz .zip常用归档调用压缩压缩比及压缩速度:gzip命令:压缩查看压缩文件:gunzip命令:解压bzip2:命令压缩查看压缩文件bunzip2命令:解压xz命令:压缩查看压缩文件...
    99+
    2022-06-04
    linux压缩文件 linux文件解压
  • Linux文件压缩和解压缩的命令
    本篇内容介绍了“Linux文件压缩和解压缩的命令”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!1、tar:tar命令:tar [选项...]...
    99+
    2023-06-13
  • c语言压缩文件详细讲解
    目录c语言压缩文件一、单文件压缩二、多文件压缩三、多文件异步压缩四、压缩文件夹c语言压缩文件 话说当今压缩市场三足鼎立,能叫上名号的有zip、rar、7z。其中zip是压缩界的鼻祖,...
    99+
    2022-11-12
  • Python文件的压缩与解压
    目录前言:1、压缩整个文件夹2、压缩指定扩展名文件3、获取指定类型的待压缩文件列表4、解压文件前言: Python在人工智能,后台服务等领域中得到了广泛应用。由于python有着大量...
    99+
    2022-11-10
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作