Link Details

Link 1096875 thumbnail
User 379952 avatar

By eugenparaschiv
via baeldung.com
Published: Jan 16 2014 / 07:54

How to convert an InputStream to a String using plain Java, Guava or Commons IO.
  • 12
  • 3
  • 457
  • 1497

Comments

Add your comment
User 776377 avatar

lburnham123 replied ago:

1 votes Vote down Vote up Reply

Discussing converting streams to strings without discussing encodings misses the mark - using String,getBytes() is just bad.

User 851745 avatar

Greg Brown replied ago:

0 votes Vote down Vote up Reply

"using String,getBytes() is just bad". Agreed. But he was just using that to simulate an actual input stream. He didn't use it in any of the examples he gave for decoding the stream.

User 379952 avatar

eugenparaschiv replied ago:

0 votes Vote down Vote up Reply

Agreed - that is why all 3 examples specify their encoding so that the system default is not used. Cheers, Eugen.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Node.js
Written by: Bert Belder
Featured Refcardz: Top Refcardz:
  1. Design Patterns
  2. OO JS
  3. Cont. Delivery
  4. Java EE7
  5. HTML5 Mobile
  1. Debugging JavaScript
  2. OO JS
  3. JSON
  4. Ajax
  5. REST