principal-ideal-domain
principal-ideal-domain

Reputation: 4266

Convert InputStream into Stream<String> given a Charset

I want to convert an InputStream is into a Stream<String> stream given a Charset cs in such a way that stream consists of the lines of is. Furthermore a line of is should not be read immediately but only in case stream needs it.

Upvotes: 39

Views: 22407

Answers (1)

Costi Ciudatu
Costi Ciudatu

Reputation: 38195

I think you can try:

Stream<String> lines = new BufferedReader(new InputStreamReader(is, cs)).lines();

Upvotes: 67

Related Questions