Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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 从SFTP位置下载zip或exe文件_Java_Sftp_J2ssh - Fatal编程技术网

Java 从SFTP位置下载zip或exe文件

Java 从SFTP位置下载zip或exe文件,java,sftp,j2ssh,Java,Sftp,J2ssh,下面是我的应用程序中的两个片段,我使用J2SSH jar访问SFTP 第一个: ......... ......... //Open the SFTP channel com.sshtools.j2ssh.SftpClient client = sshClient.openSftpClient(); // writing from source path to outputstream client.get("/Repository/Test/index.zip", outputSt

下面是我的应用程序中的两个片段,我使用J2SSH jar访问SFTP

第一个:

 .........
 .........
 //Open the SFTP channel
 com.sshtools.j2ssh.SftpClient client = sshClient.openSftpClient();
 // writing from source path to outputstream
 client.get("/Repository/Test/index.zip", outputStream);            
 ........
 ........
第二个(JSP文件):

在应用程序中,一切正常,没有任何例外。 下载文本文件时没有问题。 但当我试图下载zip或exe文件时,它缺少了一些东西。 即使下载成功,文件也无法提取或无法执行


请告诉我哪一个可能是问题所在。。。。特别是它应该适用于exe文件…

对于我使用的这种工作


我用它来做这种工作

response.setContentType("application/octet-stream");
response.setHeader("Content-disposition","attachment; filename=index.zip");
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
client.fillOutputStream(bos);    //  this method calls to first block code.
bos.flush();
bos.close();
response.flushBuffer(); 
StandardFileSystemManager manager = new StandardFileSystemManager();
FileObject target = manager.resolveFile("file://" + path + File.separator + filenameTarget);
FileObject source = manager.resolveFile(sftpUri + path + File.separator + filenameSource, options);
target.copyFrom(fichierSource, Selectors.SELECT_SELF);