PrintWriter println Example
PrintWriter class println example. This example shows you how to use println method.
PrintWriter class println example. public void println() Terminates the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
Here is the code
/**
* @ # Println.java
* A class reprsenting use to println method
* of PrintWriter class in java.io package
* version 10 June 2008
* author Rose India
*/
import java.io.*;
public class Println {
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("Rose"));
printWriter.println();
printWriter.print(new String("India"));
System.out.println(stringWriter.getBuffer());
// Close the PrintWriter and String Writer objects.
stringWriter.close();
printWriter.close();
}
} |
|