集册 Java实例教程 创建清单

创建清单

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

534
创建清单


//package com.nowjava;

import java.io.BufferedReader;

import java.io.File;
/** from 
时 代 J     a    v  a - nowjava.com**/

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import java.util.zip.ZipEntry;

import java.util.zip.ZipInputStream;


public class Main {

    public static List<String> createManifest(ZipInputStream zip) {

        List<String> zipContents = new ArrayList<String>();


        try {

            ZipEntry zipEntry = zip.getNextEntry();
            /* from 
            n o w  j a v a  . c o m*/


            while (zipEntry != null) {

                if (!zipEntry.isDirectory()) {

                    zipContents.add(normalizeFileName(zipEntry.getName()));

                }

                zipEntry = zip.getNextEntry();

            }


            zip.close();

        } catch (IOException e) {

            e.printStackTrace();

        }


        return zipContents;

    }


    public static List<String> createManifest(File file) {

        List<String> files = new ArrayList<String>();


        BufferedReader reader = null;

        try {

            reader = new BufferedReader(new FileReader(file));

            String line = null;

            while ((line = reader.readLine()) != null) {

                files.add(normalizeFileName(line));

            }


        } catch (IOException e) {

            e.printStackTrace();

        } finally {

            try {

                reader.close();

            } catch (IOException e) {

                e.printStackTrace();
展开阅读全文