Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import java.util.zip.ZipEntry;

import java.util.zip.ZipOutputStream;

public class Main {
    public static void doEntry(Context context, ZipOutputStream zout, int resId, String dest) throws Exception {
        InputStream in = null;
        try {
            zout.putNextEntry(new ZipEntry(dest));
            copyStream(in = context.getResources().openRawResource(resId), zout);
        } finally {
            zout.closeEntry();
            in.close();
        }
    }

    private static void copyStream(InputStream input, OutputStream output) throws IOException {
        byte[] buff = new byte[4096];
        int len;
        while ((len = input.read(buff)) != -1) {
            output.write(buff, 0, len);
        }
    }
}