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

📄 gzipcompress.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
字号:
//: GZIPcompress.java
// Uses Java 1.1 GZIP compression to compress
// a file whose name is passed on the command
// line.
import java.io.*;
import java.util.zip.*;

public class GZIPcompress {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new FileReader("c:\\GZIPcompress.java"));
      BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream("c:\\test.gz")));
      
	  System.out.println("Writing file");
      int c;
      while((c = in.read()) != -1)
          out.write(c);
      in.close();
      out.close();
      System.out.println("Reading file");

      BufferedReader in2 = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream("c:\\test.gz"))));
      String s;
      while((s = in2.readLine()) != null)
          System.out.println(s);

    } catch(Exception e) {
        e.printStackTrace();
    }
  }
} ///:~

⌨️ 快捷键说明

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