java下载的zip文件已损坏

我正在使用appache commons方法从FTP服务器下载一些文件,并且zip文件已损坏。我可以下载该文件并将其放置在正确的文件夹中,但是当我打开它时,文件丢失了,并且声称它已损坏,如果我尝试使用普通的.txt文件进行下载,则可以正常工作。

public boolean downloadFiles(String folder, String file) throws Exception
{
    File output = new File(folder + "\\" + file);
    System.out.println(output);
    FileOutputStream out    =   new FileOutputStream(output);
    client.retrieveFile(file, out);
    out.close();

    if(output.exists())      
        return true;
    else
        return false;

}
费边(Fabian Tschachtli)

确保对FTP传输使用二进制模式。txt文件可以工作的事实表明,这很可能是您的问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章