Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.util.zip.ZipOutputStream;

public class Main {
    public static ZipOutputStream createZipOutputStream(File file, int compressLevel) {
        try {
            if (!file.exists()) {
                file.createNewFile();
            }
            final FileOutputStream fos = new FileOutputStream(file);
            final ZipOutputStream zos = new ZipOutputStream(fos);
            zos.setLevel(compressLevel);
            return zos;
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }

    }
}