PrintWriter print Example
PrintWriter class print example. This example shows you how to use print method.
PrintWriter class print example.
Here is the code
/**
* @ # Print9.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 Print9 {
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 String("RoseIndia"));
System.out.println(stringWriter.getBuffer());
// Close the PrintWriter and String Writer objects.
stringWriter.close();
printWriter.close();
}
} |
|