我必须使用SFTP从ZIP存档(只有一个文件,我知道它的名称)中获取文件内容.我唯一拥有的是ZIP InputStream.大多数示例显示如何使用此语句获取内容:
ZipFile zipFile = new ZipFile("location");
Run Code Online (Sandbox Code Playgroud)
但正如我所说,我的本地机器上没有ZIP文件,我不想下载它.是否InputStream足以阅读?
UPD:这是我的方式:
import java.util.zip.ZipInputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class SFTP {
public static void main(String[] args) {
String SFTPHOST = "host";
int SFTPPORT = 3232;
String SFTPUSER = "user";
String SFTPPASS = "mypass";
String SFTPWORKINGDIR = "/dir/work";
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
try {
JSch jsch = new JSch();
session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
session.setPassword(SFTPPASS);
java.util.Properties config …Run Code Online (Sandbox Code Playgroud) 我必须使用现有的方法,就像saveAttachment(Attachment attachment)在哪里Attachment有一个File attribute.
我的问题是我正在检索a byte[]并且我想使用此方法保存它.我怎么能有一个"本地" File只是为了储蓄?
对不起,如果我的问题很愚蠢,我对Java中的文件了解不多.