PrintWriter printf Example
PrintWriter class printf example. This example shows you how to use printf method.
PrintWriter class printf example. public PrintWriter printf(Locale l, String format, Object... args) A convenience method to write a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.
Here is the code
/**
* @ # Printf.java
* A class reprsenting use to printf method
* of PrintWriter class in java.io package
* version 12 June 2008
* author Rose India
*/
import java.io.*;
import java.util.*;
public class Printf {
public static void main(String args[]) {
Locale l = new Locale(Locale.FRENCH.toString(),Locale.FRANCE.toString());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
printWriter.printf(l, "Locale %s",l.getCountry());
//System.out.println(stringWriter.getBuffer());
}
} |
|