Originally posted by saikrishna cinux:
what is the difference between PrintStream and PrintWriter?
Haven't you Google for this information....
Also check out this link.. Character streams
---From JAVA API Specifications
public class PrintStream
A PrintStream adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag that can be tested via the checkError method. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.
All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes.
public class PrintWriter
Print formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.
Unlike the PrintStream class, if automatic flushing is enabled it will be done only when one of the println() methods is invoked, rather than whenever a newline character happens to be output. The println() methods use the platform's own notion of line separator rather than the newline character.
Methods in this class never throw I/O exceptions. The client may inquire as to whether any errors have occurred by invoking checkError().
Tell us what exactly you don't understand....We will appreciate your kind efforts regarding this issue......
But first of all come up with exact problem ...
[ September 12, 2006: Message edited by: Ankur Sharma ]
If what you want to do is to do "printing" operations and the ultimate destination is an OutputStream, use an OutputStreamWriter between your PrintWriter and your OutputStream.