Solved

Telnet Input Stream

Posted on 2004-04-05
3
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 10760398
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
ID: 10760401

    baos.write(buf);

should be


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

Expert Comment

by:CEHJ
ID: 10767254
8-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

710 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