1. Unzip the zip file
/*** Unzip the input zip stream, java default decompression can only handle UTF-8 encoded file or directory name, otherwise it will be reported malformed exception *@paramis input stream *@paramOutputFolder target Folder *@paramencoding for file and directory names in the charset zip file *@throwsIOException When the decompression error is thrown*/Private voidUnzip (InputStream is, String OutputFolder, Charset Charset)throwsIOException {byte[] buffer =New byte[Buffer_size]; Zipinputstream ZiS=NewZipinputstream (NewBufferedinputstream (IS), CharSet); ZipEntry ze=NULL; while((Ze = zis.getnextentry ())! =NULL) {String fileName=Ze.getname (); File NewFile=NewFile (OutputFolder + file.separator +fileName); if(Ze.isdirectory ()) {newfile.mkdirs (); } Else{newfile.getparentfile (). Mkdirs (); FileOutputStream Fos=NewFileOutputStream (NewFile); Bufferedoutputstream Bos=NewBufferedoutputstream (FOS); intLen; while(len = zis.read (buffer)) > 0) {bos.write (buffer,0, Len); } bos.close (); }} zis.closeentry (); Zis.close ();}
Java utility Code I have accumulated