printWriter append1 Example
printWriter class append example. This example shows you how to use append method.
PrintWriter class append example. Append method with its constructor used in the program takes single character of up to 16-bit only. method adds the character data to the writer in which it is been called. here PrintWriter class is used as the sub class of the abstract writer class.
Here is the code:-
/**
* @Program uses append method to attach data to PrintWriter
* object that later writes the data to the character output stream
* created for the specified abstract pathname file;
* Append1.java
* Author:-RoseIndia Team
* Date:-5-july-2008
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
public class Append1 {
public static void main(String args[]) throws IOException {
File stream = new File("c:\Desktop\krishna.txt");
PrintWriter out = new PrintWriter(stream);
out.println("am i cool");
out.print("boolean answer: ");
out.append('T');
out.append('r');
out.append('u');
out.append('e');
out.checkError();
}
} |
Output of the program:-
Result is generated on the specified abstract pathname file and not on the console
am i cool
boolean answer: True |
|