Solved

Redirecting the output of a PrintWriter to a StringObject

Posted on 2004-09-22
4
319 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

772 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

13 Experts available now in Live!

Get 1:1 Help Now