Re: [JSch-users] Always get -1 from inputstream
Status: Alpha
Brought to you by:
ymnk
From: <ym...@jc...> - 2006-12-21 08:37:57
|
+-From: "Han, Zhi (Zhi)" <zh...@al...> -- |_Date: Thu, 21 Dec 2006 16:00:40 +0800 _______________ | |Actually, what we need is to read remote file via sftp. We don't need a |local copy of remote file. For example we'll read 1500 bytes of remote |file and process the content then read next 1500 bytes util we got -1. |So we're investigating the ChannelSftp.getInputStream method JSch |offered. | JSch jsch = new JSch(); | Session session = jsch.getSession(user, host, 22); | AUserInfo ui = new AUserInfo(); | ui.setPassword(passwd + ""); | session.setUserInfo(ui); | session.connect(); | Channel channel = session.openChannel("sftp"); | channel.connect(); | ChannelSftp c = (ChannelSftp) channel; InputStream in=c.get("/tmp/foo"); |