Solved

Telnet Input Stream

Posted on 2004-04-05
3
264 Views
Last Modified: 2006-11-17
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,

0
Comment
Question by:sladej
  • 3
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
Comment Utility
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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility

    baos.write(buf);

should be


    baos.write((byte)buf);
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
8-)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now