[英]I keep getting java.io.FileNotFoundException with my zip extractor
Could anybody help me with my java zip extractor as stated in the title I keep getting java.io.FileNotFoundException on the folders with files in them 如标题中所述,有人可以帮助我使用我的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();
}
}
error log http://pastebin.com/crMKaa37 错误日志http://pastebin.com/crMKaa37
values 价值观
static String tempDir = System.getProperty("java.io.tmpdir");
public static File Deobf = new File(tempDir + "Deobf");
public static String Deobf2 = Deobf.toString();
entire code paste http://pastebin.com/1vTfABR1 整个代码粘贴http://pastebin.com/1vTfABR1
I have copy pasted same code and it is working fine. 我已经复制粘贴相同的代码,并且工作正常。 I think u dont have administrator permission on C drive.
我认为您没有C盘的管理员权限。 login As Administrator and run .
以Administrator身份登录并运行。 it will work.
它会工作。 Access Denied Exception will come when u don have administrator level of permission on C drive.
当您在C盘上没有管理员级别的权限时,将出现“访问被拒绝异常”。
The problem is Your doing 问题是你在做什么
String Deobf2 = Deobf.toString();//this does not give the location of the file
use 采用
file.getAbsolutePath();
in your case Deobf.getAbsolutePath();
在您的情况下
Deobf.getAbsolutePath();
instead. 代替。 Check http://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/ if you want to get the path only till the parent directory check this How to get absolute path of directory of a file?
检查http://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/如果你想获得只有直到父目录检查这个路径如何获得文件目录的绝对路径?
已解决问题的地方更改了一些代码,以供任何想要在此处获取工作zip提取代码副本的人使用,请访问http://pastebin.com/bXL8pUSg zip输出中的变量Deobf2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.