1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. JAVA認證基礎知識:Java文件解壓縮示例

        時間:2020-09-30 15:37:25 JAVA認證 我要投稿

        JAVA認證基礎知識:Java文件解壓縮示例

          Java實現壓縮文件的解壓縮操作,缺點是壓縮文件內不能含有文件名為中文的的文件,否則會出現如下錯誤:

        JAVA認證基礎知識:Java文件解壓縮示例

          Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED

          at java.util.zip.ZipCoder.toString(Unknown Source)

          at java.util.zip.ZipInputStream.readLOC(Unknown Source)

          at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)

          at com.javatest.techzero.gui.ZipFileDemo.main(ZipFileDemo.java:22)

          代碼:

          package com.javatest.techzero.gui;

          import java.io.File;

          import java.io.FileInputStream;

          import java.io.FileOutputStream;

          import java.io.InputStream;

          import java.io.OutputStream;

          import java.util.zip.ZipEntry;

          import java.util.zip.ZipFile;

          import java.util.zip.ZipInputStream;

          public class ZipFileDemo {

          @SuppressWarnings("resource")

          public static void main(String args[]) throws Exception {

          File file = new File("d:" + File.separator + "test.zip");

          File outFile = null;

          ZipFile zipFile = new ZipFile(file);

          ZipInputStream zipInput = new ZipInputStream(new FileInputStream(file));

          ZipEntry entry = null;

          InputStream input = null;

          OutputStream out = null;

          while ((entry = zipInput.getNextEntry()) != null) {

          System.out.println("開始解壓縮" + entry.getName() + "文件。。。");

          outFile = new File("d:" + File.separator + entry.getName());

          if (!outFile.getParentFile().exists()) {

          outFile.getParentFile().mkdir();

          }

          if (!outFile.exists()) {

          outFile.createNewFile();

          }

          input = zipFile.getInputStream(entry);

          out = new FileOutputStream(outFile);

          int temp = 0;

          while ((temp = input.read()) != -1) {

          //System.out.println(temp);

          out.write(temp);

          }

          input.close();

          out.close();

          }

          System.out.println("Done!");

          }

          }

        【JAVA認證基礎知識:Java文件解壓縮示例】相關文章:

        Java文件解壓縮示例05-12

        Java文件解壓縮實例詳解201605-15

        JAVA認證基礎知識:Java獲取當前的系統時間11-18

        Java認證基礎知識:java字符串轉化整型問題11-18

        JAVA認證簡介11-29

        JAVA認證基礎知識:JavaNativeInterface學習小結11-18

        java認證考試介紹11-29

        JAVA認證考試細則11-29

        SUN JAVA認證介紹05-13

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>