茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    JSP上面實(shí)現(xiàn)目錄壓縮
    來源:易賢網(wǎng) 閱讀:1347 次 日期:2015-01-27 14:41:34
    溫馨提示:易賢網(wǎng)小編為您整理了“JSP上面實(shí)現(xiàn)目錄壓縮”,方便廣大網(wǎng)友查閱!

    zip方法 zipPath參數(shù)為保存zip的文件路徑 srcPath參數(shù)為需要壓縮的目錄 在linux window上面測(cè)試無問題!主要是編碼問題比較麻煩~要是有其他異常 請(qǐng)留言 或者 有什么更好的方法 歡迎給更多的意見

    //zip zhe folder

    void zip(String zipPath, String srcPath,javax.servlet.jsp.JspWriter out) throws Exception {

    FileOutputStream output = null;

    ZipOutputStream zipOutput = null;

    try{

    output = new FileOutputStream(zipPath);

    zipOutput = new ZipOutputStream(output);

    zipEntry(zipOutput,srcPath,srcPath,zipPath);

    }catch(Exception e){

    out.print("file zip error");

    }finally{

    if(zipOutput!=null)zipOutput.close();

    }

    out.print("zip ok"+zipPath);

    }

    //add the zip entry

    void zipEntry(ZipOutputStream zipOs, String initPath,String filePath,String zipPath) throws Exception {

    String entryName = filePath;

    File f = new File(filePath);

    if (f.isDirectory()){// ??

    String[] files = f.list();

    for(int i = 0; i < files.length; i++)

    zipEntry(zipOs, initPath, filePath + File.separator + files[i],zipPath);

    return;

    }

    String chPh = initPath.substring(initPath.lastIndexOf("/") + 1);// ?????

    int idx=initPath.lastIndexOf(chPh);

    if (idx != -1) {

    entryName = filePath.substring(idx);

    }

    ZipEntry entry;

    entry = new ZipEntry(entryName);

    File ff = new File(filePath);

    if(ff.getAbsolutePath().equals(zipPath))return;

    entry.setSize(ff.length());

    entry.setTime(ff.lastModified());

    //the CRC efficacy

    entry.setCrc(0);

    CRC32 crc = new CRC32();

    crc.reset();

    zipOs.putNextEntry(entry);

    int len = 0;

    byte[] buffer = new byte[2048];

    int bufferLen = 2048;

    FileInputStream input =null;

    try{

    input = new FileInputStream(filePath);

    while ((len = input.read(buffer, 0, bufferLen)) != -1) {

    zipOs.write(buffer, 0, len);

    crc.update(buffer, 0, len);

    }

    }catch(Exception e){

    }finally{

    if(input!=null)input.close();

    }

    entry.setCrc(crc.getValue());

    }

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看腳本欄目
    易賢網(wǎng)手機(jī)網(wǎng)站地址:JSP上面實(shí)現(xiàn)目錄壓縮
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報(bào)班

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)