`
peng_jian_ming
  • 浏览: 255124 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Java对ZIP压缩包文件进行解压缩

    博客分类:
  • Java
阅读更多
/**
* 此方法是用来进行压缩包文件解压缩使用
* @param inFile
* @param outFile
* @return
*/
private boolean uncoilZIP(File inFile,File outFile){
   if(!inFile.exists()){
    logger.info("添加皮肤com.yc.eap.plugin.base.skin.action.SkinTnsert类抛出异常,未发现上传压缩包");
    return false;
   }
   GZIPInputStream input = null;
   OutputStream output = null;
   try {
    if(!outFile.exists()){
     if(!outFile.createNewFile()){
      logger.info("添加皮肤com.yc.eap.plugin.base.skin.action.SkinTnsert类抛出异常,解压缩后的文件目录不存在!");
      return false;
     }
    }
    input = new GZIPInputStream(new FileInputStream(inFile));
    output = new FileOutputStream(outFile);
    byte block[] = new byte[1024];
    int length = 0;
    while((length = input.read(block))!=-1){
     output.write(block,0,length);
    }
    output.flush();
    return true;
   } catch (IOException e) {
    logger.error("添加皮肤com.yc.eap.plugin.base.skin.action.SkinTnsert类抛出异常"+e.getMessage());
    return false;
   }finally{
    try {
     if(input!=null){
      input.close();
     }
     if(output!=null){
      output.close();
     }
    } catch (IOException e) {
     logger.error("添加皮肤com.yc.eap.plugin.base.skin.action.SkinTnsert类关闭文件流出错"+e.getMessage());
    }
   }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics