Java教程

java 本地压缩zip包并且下载 两个功能

本文主要是介绍java 本地压缩zip包并且下载 两个功能,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
//生成zip
    public boolean createCardImgZip(String sourcePath, String zipName) {  
    // TODO Auto-generated method stub  
    boolean result = false;  
    String zipPath = "D:/test/";  
    File sourceFile = new File(sourcePath);  
    FileInputStream fis = null;  
    BufferedInputStream bis = null;  
    FileOutputStream fos = null;  
    ZipOutputStream zos = null;  

    if (sourceFile.exists() == false) {  
        System.out.println("File catalog:" + sourcePath + "not exist!");  
    } else {  
        try {  
            if(!new File(zipPath).exists()){  
                new File(zipPath).mkdirs();  
            }  
            File zipFile = new File(zipPath + "/" + zipName + ".zip");  
            if (zipFile.exists()) {  
                System.out.println(zipPath + "Catalog File: " + zipName + ".zip" + "pack file.");  
    
这篇关于java 本地压缩zip包并且下载 两个功能的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!