Android Question How access ByteArrayInputStream from java

drgottjr

Expert
Licensed User
Longtime User
not sure what you mean by "call bytearrayinputstream" or what you want to do with one, but to create an instance of one, try:

B4X:
dim bais as javaobject
bais.initializenewinstance("java.io.ByteArrayInputStream",null)

then you might try things like these:

B4X:
dim int bytesavailable = bais.runmethod("available",null)
dim bytes() as byte = bais.runmethod("readAllbytes",null)
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User
Thanks for this. My intent is to convert a byte array to an InputStream using bytearrayinputstream , Below is my thought of how to achieve but I welcome being corrected

B4X:
dim bais as javaobject
dim sa() as byte

bais.initializenewinstance("java.io.ByteArrayInputStream",null)
dim in as InputStream = bais.runmethod("getBinaryStream ",sa)
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User

Sorry about this Like I been trying to do it the hard way via java when inputstream has a method already to do that very thing called InitializeFromBytesArray, of which you most definitely know. Sorry for misusing your time
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…