Java 从SFTP位置下载zip或exe文件
下面是我的应用程序中的两个片段,我使用J2SSH jar访问SFTP 第一个: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
.........
.........
//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);