集册 Java实例教程 获取邮政编码条目名称

获取邮政编码条目名称

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

424
获取邮政编码条目名称


//package com.nowjava;
/*时 代      J a v a   公   众 号 - nowjava.com 提 供*/

import java.io.File;


import java.io.IOException;


import java.io.UnsupportedEncodingException;

import java.util.ArrayList;


import java.util.Enumeration;

import java.util.zip.ZipEntry;

import java.util.zip.ZipException;
/*来自 
 时 代 J a v a 公 众 号*/

import java.util.zip.ZipFile;


public class Main {

    private static final String ENCODE_GB2312 = "GB2312";

    private static final String ENCODE_8859_1 = "8859_1";


    public static ArrayList<String> getEntriesNames(File zipFile)

            throws ZipException, IOException {

        ArrayList<String> entryNames = new ArrayList<String>();

        Enumeration<?> entries = getEntriesEnumeration(zipFile);

        while (entries.hasMoreElements()) {

            ZipEntry entry = ((ZipEntry) entries.nextElement());

            entryNames.add(new String(getEntryName(entry).getBytes(

                    ENCODE_GB2312), ENCODE_8859_1));

        }

        return entryNames;

    }


    public static Enumeration<?> getEntriesEnumeration(File zipFile)

            throws ZipException, IOException {

        ZipFile zf = new ZipFile(zipFile);

        
展开阅读全文