Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
Java Windows XP阻止由我的程序创建的zip文件_Java_Windows_Zip - Fatal编程技术网

Java Windows XP阻止由我的程序创建的zip文件

Java Windows XP阻止由我的程序创建的zip文件,java,windows,zip,Java,Windows,Zip,我有以下java代码来创建zip文件。该文件在linux上运行良好,但Windows XP的本机提取器正在阻止它。建议的解决方法(转到文件属性并取消阻止)也不起作用。我在网上看到过类似的问题,在stackoverflow上也看到过类似的帖子,但这些解决方案都不适合我。任何关于问题起因的想法 ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ZipOutputStream zipFile = new ZipOutputStre

我有以下java代码来创建zip文件。该文件在linux上运行良好,但Windows XP的本机提取器正在阻止它。建议的解决方法(转到文件属性并取消阻止)也不起作用。我在网上看到过类似的问题,在stackoverflow上也看到过类似的帖子,但这些解决方案都不适合我。任何关于问题起因的想法

ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ZipOutputStream zipFile = new ZipOutputStream(byteOut);
loop {
    byte [] tempData = "some data".getBytes("UTF-8"); 
    ZipEntry entry = new ZipEntry("blah.txt"); //no path here
    entry.setSize(tempData.length); //read somewhere that this might solve the issue, didn't work
    entry.setTime((new Date()).getTime()); //tried with and without this.. this is probably redundent since putNextEntry sets the time to current too.
    zipFile.putNextEntry(entry);  
    zipFile.write(tempData);
    zipFile.closeEntry();
     }
zipFile.close();         
附言

  • 我的windows计算机上没有windows defender
  • 我试过设置zip条目的大小,但仍然不起作用
  • zip条目中没有指定绝对路径,路径中也没有斜杠
  • 谢谢

    编辑1:是的,我在其他使用Windows XP的机器上进行了测试,结果相同。我下载了7zip,但不知道如何检查压缩方法。如果有人能告诉我做这件事的步骤,我可以将压缩方法添加到注释中


    编辑2:我使用windows本机提取向导,该向导显示“windows已阻止对这些文件的访问,以帮助保护您的计算机”。在这条消息下面有一个链接,上面写着“Windows阻止标记为不受信任的文件。为什么阻止这些文件以及如何打开它们”。单击该链接可提供无效的解决方法(文件属性->取消阻止)。

    刚刚解决了问题,我的输入文件名中有一个带有:的时间戳,windows对此感到震惊


    ZipEntry条目=新ZipEntry(“blah.txt”);奇怪的在另一台机器上测试?还有,它使用了什么压缩方法(7-zip可以告诉你)?“块”是什么意思?您的意思是它将zip设置为不受信任的,还是解压时出错?如果出现错误,错误是什么?