saran
saran

Reputation: 1291

string to stream in java without bytearrayinputstream

How to convert string to stream in java without using bytearrayinputstream and example?

Upvotes: 0

Views: 597

Answers (2)

Michael Borgwardt
Michael Borgwardt

Reputation: 346536

You could extend the InputStream class and implement the read() method such that it returns data from a String.

But it would be really useless to do that when using a ByteArrayInputStream is so much simpler and easier.

Upvotes: 2

Nikunj
Nikunj

Reputation: 3128

InputStream is = new StringInputStream(string);

Upvotes: 0

Related Questions