Solved

Redirecting the output of a PrintWriter to a StringObject

Posted on 2004-09-22
4
321 Views
Last Modified: 2012-08-13
hi Experts,
             I need to redirect the Output of a printwriter to a String object. It is not possbile to write to a file and read that file bcos i am Writing BLOB Ojects from a database. Is there any way to do this..

Thanx
Novice..Programmer
0
Comment
Question by:FearFactor_x
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12121117
Use a PipedOutputStream as the Output for the PrintWriter, and read the data from the associated PipedInputStream (possibly using a StringWriter to build the string...)
0
 
LVL 11

Accepted Solution

by:
cjjclifford earned 125 total points
ID: 12121125
Or even simpler, use a ByteArrayOutputStream with the PrintWriter, and use the "toString()" method after the final flush()/close() on the PrintWriter to convert the ByteArray to a String...
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12121153
I suggest to use the Stream to write and read the data because if the data are really big there could be some problem.
So, write to the OutputStream and read from the InputStream (like loopback).
Hope this could help.
Bye, Giant.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12121165
Sorry.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question