PrintWriter format Example
PrintWriter class format example. This example shows you how to use format method.
PrintWriter class format example. public PrintWriter format(Locale , String , Object... args) Writes 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
/**
* @ # Format.java
* A class reprsenting use to format method
* of PrintWriter class in java.io package
* version 12 June 2008
* author Rose India
*/
import java.io.*;
import java.util.*;
public class Format {
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);
int i = 0;
printWriter.format(l, "Locale %s",l.getCountry());
System.out.println(stringWriter.getBuffer());
}
} |
|