Jump to content
  • Advertisement
Sign in to follow this  

Java Can't read non-CR lines from inputstream

This topic is 2689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I'm using Ganymed to establish an SSH telnet session. I am able to read the information
coming from the telnet session as long as there is a carriage return.

I can send 'whoami' and read the response since it has a carriage return.

However, when I send 'passwd' the response does not contain a carriage return and I cannot read it.
I also can't read the ' it uses as a prompt for my input as it also doesn't have a carriage return.
What can I do to get all the bytes and not just those which end with a carriage return?

As a side issue, what's the point of .available()? It seems to always return 0 even though there
is stuff to be read. I've read "The available method for class InputStream always returns 0." so what's the point?

Below is what I am using to read the stream.


InputStream m_input = new StreamGobbler(m_session.getStdout());
InputStream m_error = new StreamGobbler(m_session.getStderr());
String m_inputText = "";

byte[] buff = new byte[4096];

if (m_input.available() > -1)
int len = in.read(buff);
if (len == -1)
m_inputText += new String(buff, 0, len);
catch (Exception e)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!