Solved

Redirecting the output of a PrintWriter to a StringObject

Posted on 2004-09-22
4
320 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 119
Checkbox and ListView in Android Layout 4 56
Responding to Java JComponent extended classes's resize event 4 50
jar file executable 12 39
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now