• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert OutStream to String  RSS feed

 
Kamalakar Sridhara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have OutputStream with me. And I am printing this using PrintWriter.

PrintWriter out = new PrintWriter(os);

Instead, I wanna convert OutputStream to String.
Could anyone help me ??
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Converting an OutputStream to a String is impossible.
Strings are immutable - for instance.

What problem do you want to solve?
 
Irinel Nacu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kamalakar Sridhara:
I have OutputStream with me. And I am printing this using PrintWriter.

PrintWriter out = new PrintWriter(os);

Instead, I wanna convert OutputStream to String.
Could anyone help me ??


Hi,
there is java.io.ByteArrayOutputStream
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually java.io.StringWriter would probably be what he's looking for.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!