List of usage examples for java.util Formatter Formatter
public Formatter(OutputStream os, String csn) throws UnsupportedEncodingException
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); String name = "from java2s.com"; formatter.format("Hello %s !", name); System.out.println(formatter.ioException()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format(Locale.US, "Hello %s !", name); // print the formatted string with specified locale System.out.println(formatter + " " + formatter.locale()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string with default locale System.out.println(formatter + " " + formatter.locale()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string with default locale System.out.println(formatter); System.out.println(formatter.locale()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string with default locale System.out.println(formatter); // print the output System.out.println(formatter.out()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string with default locale System.out.println(formatter); // print the formatter as a string System.out.println(formatter.toString()); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();//from w w w .j a v a2s . c o m System.out.println("Formatter Flushed."); }
From source file:Main.java
public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer, Locale.US); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // close the formatter formatter.close();//from w ww .ja v a 2 s . c o m // attempt to access the formatter results in exception System.out.println(formatter); }
From source file:Main.java
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { Formatter formatter = new Formatter("generated/format.txt", "ASCII"); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();/*from www . j av a 2s . co m*/ System.out.println("Formatter Flushed."); }
From source file:Main.java
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { Formatter formatter = new Formatter(new File("generated/format.txt"), "ASCII"); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();/*from w w w . j a v a 2 s.c om*/ System.out.println("Formatter Flushed."); }