Java-解压缩文件返回FileNotFoundException

Java-解压缩文件返回FileNotFoundException,java,zip,unzip,Java,Zip,Unzip,我正在尝试使用我在网上找到的方法解压缩一个文件 public static void unzipFile(String zipFile, String outputFolder) throws IOException { File destDir = new File(outputFolder); if (!destDir.exists()) { destDir.mkdir(); } ZipInput

我正在尝试使用我在网上找到的方法解压缩一个文件

    public static void unzipFile(String zipFile, String outputFolder) throws IOException {
        File destDir = new File(outputFolder);
        if (!destDir.exists()) {
            destDir.mkdir();
        }
        ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFile));
        ZipEntry entry = zipIn.getNextEntry();
        while (entry != null) {
            String filePath = outputFolder + File.separator + entry.getName();
            if (!entry.isDirectory()) {
                extractFile(zipIn, filePath);
            } else {
                File dir = new File(filePath);
                dir.mkdir();
            }
            zipIn.closeEntry();
            entry = zipIn.getNextEntry();
        }
        zipIn.close();
    }

    public static void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
        byte[] bytesIn = new byte[4096];
        int read = 0;
        while ((read = zipIn.read(bytesIn)) != -1) {
            bos.write(bytesIn, 0, read);
        }
        bos.close();
    }
然而,我一直在获取FileNotFoundException
BufferedOutputStream bos=newbufferedoutputstream(newfileoutputstream(filePath))

错误消息:
java.io.FileNotFoundException:/Users/michael/NetBeansProjects/test/build/web/test\u ZIP/my html/css/bootstrap-theme.css(非目录)

我试图用:

File file = new File(filePath);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
但也不管用。控制台中会显示相同的错误消息

我的ZIP文件结构:

my-html
|
|- css
|   |
|   |- bootstrap-theme.css
|   |- ..
|   |- ..
|
|-index.html
将此更改为:

destDir.mkdirs();
您只创建了一级目录

将此更改为:

destDir.mkdirs();

您只创建了一级目录。

确保输出文件夹的名称中没有扩展名,如“/test.zip”。将其命名为“output”或“myFolder”

确保输出文件夹的名称中没有扩展名,如“/test.zip”。将其命名为“output”或“myFolder”

您是否考虑过咨询Javadoc?“您只创建了一级目录”的哪一部分您不明白?您考虑过咨询Javadoc吗?“您只创建了一级目录”的哪一部分您不明白?