Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我一直在使用zip提取器获取java.io.FileNotFoundException_Java_File_Exception - Fatal编程技术网

我一直在使用zip提取器获取java.io.FileNotFoundException

我一直在使用zip提取器获取java.io.FileNotFoundException,java,file,exception,Java,File,Exception,有人能帮我使用我的java zip提取器吗?如标题“我一直在获取java.io.FileNotFoundException”中所述,文件夹中有文件 public void UnZip() { try { byte[] data = new byte[1000]; int byteRead; BufferedOutputStream bout = null; ZipInputStream zin = new ZipInput

有人能帮我使用我的java zip提取器吗?如标题“我一直在获取java.io.FileNotFoundException”中所述,文件夹中有文件

public void UnZip() {
    try {
        byte[] data = new byte[1000];
        int byteRead;

        BufferedOutputStream bout = null;
        ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(sourceFile)));
        ZipEntry entry;
        while ((entry = zin.getNextEntry()) != null) {
            String filename = entry.getName();
            File newfile = new File(Deobf2 + File.separator + filename);

            System.out.println("file unzip : " + newfile.getAbsoluteFile());

            new File(newfile.getParent()).mkdirs();

            FileOutputStream fos = new FileOutputStream(newfile);

            int len;
            while ((len = zin.read(data)) > 0) {
                fos.write(data, 0, len);
            }

            fos.close();
            entry = zin.getNextEntry();
        }
        zin.closeEntry();
        zin.close();

        System.out.println("Done");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
错误日志

价值观

static String tempDir = System.getProperty("java.io.tmpdir");
public static File Deobf = new File(tempDir + "Deobf");
public static String Deobf2 = Deobf.toString();
完整代码粘贴

我复制粘贴了相同的代码,它工作正常。我想你在C盘上没有管理员权限。以管理员身份登录并运行。它会起作用的。
当您在C驱动器上没有管理员级别的权限时,将出现拒绝访问异常。

问题在于您的操作

String Deobf2 = Deobf.toString();//this does not give the location of the file
使用

在您的例子中,
Deobf.getAbsolutePath()

相反。检查
如果只想在父目录之前获取路径,请检查此问题,修复了更改的一些代码 对于任何想要一份工作邮政编码的人,给你
zip输出中的变量Deobf2

您是否可以在出现故障时发布错误以及
Deobf2
&
filename
的值请检查您的文件是否确实存在!您在这里试图做什么字符串Deobf2=Deobf.toString();将Deobf file变量转换为string@Ry_dog101您是否正在尝试获取文件名?好的,以管理员身份运行我的IDE修复了部分错误,现在我收到了此错误,请尝试解压缩另一个zip文件。我认为zip.zip文件有一些问题,这些文件中包含了这个程序将用于的内容,并给出了相同类型的错误。这可能不是答案,但请尝试一次。因为我没有犯错误。请在Main.java//静态字符串tempDir=System.getProperty(“java.io.tmpdir”)中命令这一行;并将这一行更改为公共静态文件Deobf=new File(“Deobf”);。然后解压的文件将被放置在您的项目文件夹中。在“Deobf”文件夹下..好的,然后做一件事,将该zip文件发送到我的邮件中,我将运行并检查。。gangulanarendar@gmail.com
file.getAbsolutePath();