new_file_name 类似于2013-03-15-08:59:10_65.zip
fileZip = new ZipOutputStream(new FileOutputStream(new File(new_file_name)));
byte[] buffer = new byte[1024];
try{
for(String fileName:fileList)
{
FileInputStream in = null;
try{
File file = new File(fileName);
ZipEntry ze = new ZipEntry(fileName);
fileZip.putNextEntry(ze);
in = new FileInputStream(file);
int len = 0;
while((len = in.read(buffer)) > 0) {
fileZip.write(buffer, 0, len);
}
fileZip.closeEntry();
in.close();
} catch (Exception e) {
log(0, "Exception writing "+fileName+" to "+new_file_name+": "+e.toString());
}
我得到了这个例外Exception writing to 2013-03-15-09:28:20_65.zip: java.io.FileNotFoundException: (No such file or directory)
该目录具有完全权限。我也看到在文件夹中创建了一个文件,我也尝试给出 getAbsolutePath(),仍然给了我同样的异常。