This happens on some files but not on others.
1: End of file
        at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
        at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2198)
        at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1294)
        at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1266)
The code is simple:
        jsch.addIdentity("privateKeyFromOdin", sftpPrivateKey, null, null);
        session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();
        Channel channel = session.openChannel("sftp");
        channel.connect();
        channelSftp = (ChannelSftp) channel;
        Vector<ChannelSftp.LsEntry> ls = channelSftp.ls(".");
        for (ChannelSftp.LsEntry entry : ls) {
                String fileName = entry.getFilename();
                encryptedStream = channelSftp.get(fileName);//Exception thrown here
        }
What's even more odd is that this used to work well. But I don't know what changed.
I had similar issue, I was not closing inputStream returned by each "channelSftp.get(fileName)" call, try closing inputStream
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With