PrintWriter print Example
PrintWriter class print example. This example shows you how to use print method.
PrintWriter class print example. This example shows you how to use print method.
Here is the code
/**
* @ # Print8.java
* A class reprsenting use to print method
* of PrintWriter class in java.io package
* version 10 June 2008
* author Rose India
*/
import java.io.*;
public class Print8 {
public static void main(String args[]) throws Exception {
// Create a new instance of a PrintWriter object along with
// an underlying StringWriter object.
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
printWriter.print(new StringBuffer("RoseIndia"));
System.out.println(stringWriter.getBuffer());
// Close the PrintWriter and String Writer objects.
stringWriter.close();
printWriter.close();
}
} |
|