集册 Java实例教程 创建GZIP存档

创建GZIP存档

欢马劈雪     最近更新时间:2020-01-02 10:19:05

546
创建GZIP存档

// This program is free software: you can redistribute it and/or modify it

//package com.nowjava;/* 来自 N o w J a v a . c o m - 时代Java*/

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.zip.GZIPOutputStream;


public class Main {

    public static void createArchive(String outputFilename, String inputFile)

            throws IOException {

        GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(

                outputFilename));

        byte[] buf = new byte[1024];


        File file = new File(inputFile);


        FileInputStream in = new FileInputStream(file);/** from n o w  j 
展开阅读全文