PrintWriter println Example
PrintWriter class println example. This example shows you how to use println method.
PrintWriter class println example. public void println(double x) Prints a double-precision floating-point number and then terminates the line. This method behaves as though it invokes print(double) and then println().
Here is the code
/**
* @ # Println.java
* A class reprsenting use to println method
* of PrintWriter class in java.io package
* version 12 June 2008
* author Rose India
*/
import java.io.*;
public class Println4 {
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(10d);
printWriter.print(new String("India"));
System.out.println(stringWriter.getBuffer());
// Close the PrintWriter and String Writer objects.
stringWriter.close();
printWriter.close();
}
} |
/div>
|