Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to decompress the zip package automatically by the back-end server

Shulou Source: shulou.com Published: 2022-06-02 02:40:33 09月18日 Update

This article shows you how the back-end server automatically decompresses the zip package, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream / * @ author edison_kwok * / public class ZipUtils {/ * extract the zip file and delete the zip file * this method is only for Pengyuan * * @ param zipPath * @ return * @ throws Exception * / public static String unZip (String zipPath, String zipName) {String unZipName = "; FileInputStream fis = null ZipInputStream zins = null; FileOutputStream fos = null; ZipEntry entry = null; try {fis = new FileInputStream (zipPath + zipName); zins = new ZipInputStream (fis); while ((entry = zins.getNextEntry ())! = null) {String entryName = entry.getName () If (entryName.endsWith (".pdf")) {unZipName = entryName;} fos = new FileOutputStream (zipPath + entryName); byte [] buffer = new byte [2048]; int len =-1 While ((len = zins.read (buffer))! =-1) {fos.write (buffer, 0, len);} zins.closeEntry ();}} catch (IOException e) {e.printStackTrace () } finally {try {if (fos! = null) {fos.close ();} if (zins! = null) {zins.close ();} if (fis! = null) {fis.close () }} catch (IOException e) {e.printStackTrace ();}} return unZipName;}} the above is how the back-end server decompresses the zip package automatically. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Servers services content skills documents knowledge conciseness brevity that is tools articles methods more articles industries information channels channels lights reserves Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology OPPO Reno Linux Huawei