1
我們,我們試圖來解讀一個Java對象,將其轉換爲一個InputStream和SFTP過來使用JSCH APIjsch的InputStream的ObjectOutputStream和解組
基本上是一個場景 - >我們的目標是迫使jSCH到推對象的InputStream的形式而不將其轉換成一個文件,然後在這個例子中發送過來喜歡這裏:
// create a session
session = jsch.getSession(ftpUserName, ftpHost, ftpPort);
channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpTunnel = (ChannelSftp) channel;
// push the file you created using the channel created by the session
File f = new File(fileToTransmit);
>> **sftpTunnel.put(new FileInputStream(f), f.getName());**
除了我們要轉出最後一行用普通老式的InputStream無關聯到任何文件。
按照jSCH API - 不使用一個FileInputStream是可能的:
void put(InputStream src, String dst)
任何想法,以便我們如何會去嗎?
我們可以使用ObjectOutputStream嗎?有沒有辦法取出一個對象並解組它,然後將它提交給一個InputStream,而不需要在中間創建一個文件?
感謝