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

📄 main.java

📁 java的经典例子
💻 JAVA
字号:
import java.io.*;
import java.util.zip.*;

class Main {
    public static void main(String[] args) {
        if (args.length < 1) {
            System.err.println("Usage: java Main <filename>...");
            System.exit(1);
        } 

        byte[] buf = new byte[1024];
        int len;
        try {
            GZIPOutputStream os = null;
            for (int i=0; i<args.length; i++) {
                // Open the input file.
                FileInputStream is = new FileInputStream(args[i]);

                // Create a new GZIP output stream on the same output stream.
                os = new GZIPOutputStream(System.out);

                // Transfer the data from the input file to the output file.
                while ((len = is.read(buf)) >= 0) {
                    os.write(buf, 0, len);
                }

                // Close the input file.
                is.close();

                // Write out GZIP trailer information.
                os.finish();
            }
            // Now it's safe to close.
            os.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

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