I have below code to try InputStream.

            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;
           
            sis = c.getInputStream();
            sos = c.getOutputStream();
            pw = new PrintWriter(sos);
            br new BufferedReader(new InputStreamReader(sis));
           
            pw.print("list\r\n");
            pw.flush();
           
            int ch       = 0;
            int offset  = 0;
            String line = "";
            while (true) {
                ch = br.read();
                if (ch == -1)
                    break;
                else if (ch == '\n') {
                    System.out.println(line);
                    line = "";
                    offset = 0;
                }
                offset++;
                line += (char) ch;
            }
            pw.close();
            sis.close();

But ch always gets -1. Is there any wrong w/ my code?

Thanks,

Zhi