Link Details

Link 1096875 thumbnail
User 379952 avatar

By eugenparaschiv
Published: Jan 16 2014 / 07:54

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


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.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java