Telnet Input Stream

Does anyone know a quick way to convert a TelnetInputStream to byte[]?

I am using the sun.net.ftp to do a get.  It returns a TIS.

thanks,

sladejAsked:
Who is Participating?
 
CEHJCommented:
Just read it into a ByteArrayOutputStream

ByteArrayOutputStream baos = new ByteArrayOutputStream();
int buf = -1;
while((buf = telnetIn.read()) > -1) {
     baos.write(buf);
}
telnetIn.close();
byte[] bytes = baos.toByteArray();
0
 
CEHJCommented:

    baos.write(buf);

should be


    baos.write((byte)buf);
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.