Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report