Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

InputStream Problem

  Asked By: Michael    Date: Jun 06    Category: Java    Views: 481
  


how can i copy an Inputstream data to another one. because when i use

(rs is ResultSet)

is = rs.getBinaryStream();

to retrive data from database, when i close connection and the
resultset, "is" becomes unusable. im searching for a way so i can
copy the data of is to another inputstream.

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Julian Long     Answered On: Jun 06

Use the ByteArrayInputStream to read the contents of the input stream into
the buffer used to construct a ByteArrayInputStream .
Later you can then get your data  back by accessing the buffer.

 
Answer #2    Answered By: Omar Walker     Answered On: Jun 06

but java API says that ByteArrayInputStream's construtor does not
copy the buffer.

 
Answer #3    Answered By: Bonnie Hughes     Answered On: Jun 06

what the other guy meant by copying to a buffer was that u create a array of
type Byte, and copy  data from ur stream there using ByteArrayInputStream, ok

 
Answer #4    Answered By: Percy Morgan     Answered On: Jun 06

but, the read method of InputStream returns int type , how can i make
byte[] type from it?

 
Answer #5    Answered By: Aaron Kennedy     Answered On: Jun 06

if u read correctly, it returns lower end byte values only, ie integers
within byte range. Also as u must be aware byte is a subset on int only and
all bytes are coverted to int for all calculation purposes...thats why
method return type is int, you can always store it in byte array using type
casting,

 
Didn't find what you were looking for? Find more on InputStream Problem Or get search suggestion and latest updates.




Tagged: