public static String UnZip(String zipFileName)

{

  String fileName="";

  try{

     InputStream inputStream;

  byte[] buffer=new byte[1024];

    ZipFile zf= new ZipFile(zipFileName);

  Enumeration e = zf.entries();

    while(e.hasMoreElements())

{

  ZipEntry ze = (ZipEntry)e.nextElement();

  inputStream= zf.getInputStream(ze);

  fileName=ze.getName();

//new String(ze.getName().getBytes("gb2312"),"gb2312");

ze.getSize();

File file=new File("/"+fileName);

OutputStream out = new FileOutputStream(file);

int realLength;

while ((realLength = inputStream.read(buffer)) != -1)

{

         out.write(buffer, 0, realLength);

}

inputStream.close();

out.close();

} catch(Exception e)

{ e.printStackTrace(); }

return fileName; }

posted on 2010-10-13 17:28  weizeng  阅读(154)  评论(0)    收藏  举报