java doc zip_通过java.util.zip.*对java的sources源码jar包和javadoc文档zip包进行打印解压demo代码示例...

通过java.util.zip.* api实现对ejabberd-external-auth-java-1.0.0-javadoc.zip 文档zip包和ejabberd-external-auth-java-1.0.0-sources.jar源码包分别进行解压打印测试,详情见代码package com.xwood.demo.main.zip;@b@@b@import java.io.*;@b@import java.nio.charset.Charset;@b@import java.util.Enumeration;@b@import java.util.zip.ZipEntry;@b@import java.util.zip.ZipFile;@b@@b@public class UZipFile{@b@@b@  /**@b@   * 解压到指定目录@b@   */@b@  public static void unZipFiles(String zipPath,String descDir)throws IOException{@b@    unZipFiles(new File(zipPath), descDir);@b@  }@b@  @b@  /**@b@   * 解压文件到指定目录@b@   */@b@  @SuppressWarnings("rawtypes")@b@  public static void unZipFiles(File zipFile,String descDir)throws IOException@b@  {@b@    File pathFile = new File(descDir);@b@    if(!pathFile.exists())@b@    {@b@      pathFile.mkdirs();@b@    }@b@    //解决zip文件中有中文目录或者中文文件@b@    ZipFile zip = new ZipFile(zipFile, Charset.forName("GBK"));@b@    for(Enumeration entries = zip.entries(); entries.hasMoreElements();){@b@      ZipEntry entry = (ZipEntry)entries.nextElement();@b@      String zipEntryName = entry.getName();@b@      InputStream in = zip.getInputStream(entry);@b@      String outPath = (descDir+zipEntryName).replaceAll("\\*", "/");;@b@      //判断路径是否存在,不存在则创建文件路径@b@      File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));@b@      if(!file.exists())@b@      {@b@        file.mkdirs();@b@      }@b@      //判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压@b@      if(new File(outPath).isDirectory())@b@      {@b@        continue;@b@      }@b@      //输出文件路径信息@b@      System.out.println(outPath);@b@      OutputStream out = new FileOutputStream(outPath);@b@      byte[] buf1 = new byte[1024];@b@      int len;@b@      while((len=in.read(buf1))>0){@b@        out.write(buf1,0,len);@b@      }@b@      in.close();@b@      out.close();@b@    }@b@    System.out.println("******************解压完毕********************");@b@  }@b@  @b@  @b@  public static void main(String[] args) throws IOException {@b@  //解压javadoc zip压缩包@b@    File zipFile = new File("C:/test/ejabberd-external-auth-java-1.0.0-javadoc.zip");@b@    String path = "C:/test/out/";@b@    unZipFiles(zipFile, path);@b@    @b@    //解压source源码 zip压缩包@b@    zipFile = new File("C:/test/ejabberd-external-auth-java-1.0.0-sources.jar");@b@    path = "C:/test/sourceOut/";@b@    unZipFiles(zipFile, path);@b@  }@b@  @b@}

控制台结果C:/test/out/META-INF/MANIFEST.MF@b@C:/test/out/ae/teletronics/Application.html@b@C:/test/out/ae/teletronics/class-use/Application.html@b@C:/test/out/ae/teletronics/class-use/CommandType.html@b@C:/test/out/ae/teletronics/class-use/ExternalAuth.html@b@C:/test/out/ae/teletronics/class-use/InputCommand.html@b@C:/test/out/ae/teletronics/class-use/UserManagement.html@b@C:/test/out/ae/teletronics/CommandType.html@b@C:/test/out/ae/teletronics/ExternalAuth.html@b@C:/test/out/ae/teletronics/InputCommand.html@b@C:/test/out/ae/teletronics/package-frame.html@b@C:/test/out/ae/teletronics/package-summary.html@b@C:/test/out/ae/teletronics/package-tree.html@b@C:/test/out/ae/teletronics/package-use.html@b@C:/test/out/ae/teletronics/UserManagement.html@b@C:/test/out/allclasses-frame.html@b@C:/test/out/allclasses-noframe.html@b@C:/test/out/constant-values.html@b@C:/test/out/deprecated-list.html@b@C:/test/out/help-doc.html@b@C:/test/out/index-all.html@b@C:/test/out/index.html@b@C:/test/out/overview-tree.html@b@C:/test/out/package-list@b@C:/test/out/script.js@b@C:/test/out/stylesheet.css@b@******************解压完毕********************@b@C:/test/sourceOut/META-INF/MANIFEST.MF@b@C:/test/sourceOut/ae/teletronics/Application.java@b@C:/test/sourceOut/ae/teletronics/CommandType.java@b@C:/test/sourceOut/ae/teletronics/ExternalAuth.java@b@C:/test/sourceOut/ae/teletronics/InputCommand.java@b@C:/test/sourceOut/ae/teletronics/UserManagement.java@b@******************解压完毕********************

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值