⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compress.java

📁 这是一个用java编写类似于notepad文件编辑器
💻 JAVA
字号:
 import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.util.zip.GZIPOutputStream;public class Compress{    /**将from文件的内容进行压缩并且将压缩结果存入to文件中*/    public static void gzipFile(String from, String to) throws IOException {        //创建一个从from文件中读取信息的流        FileInputStream in = new FileInputStream(from);        //创建一个将数据进行压缩并且存入to文件中的流        GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(to));        //将字节从一个流复制到另一个流中        byte[] buffer = new byte[4096];        int bytes_read;        while((bytes_read = in.read(buffer)) != -1)             out.write(buffer, 0, bytes_read);        //关闭这个流        in.close();        out.close();    }     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -