List of usage examples for java.util Formatter ioException
public IOException ioException()
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[] argv) throws Exception { Formatter fmtCon = new Formatter(System.out); Formatter fmtFile = new Formatter(new FileOutputStream("test.fmt")); fmtCon.format("a negative number: %(.2f\n\n", -123.34); fmtCon.format("%8s %8s\n", "Value", "Square"); for (int i = 1; i < 20; i++) fmtCon.format("%8d %8d\n", i, i * i); // write to the file. fmtFile.format("This is a negative number: %(.2f\n\n", -123.34); fmtFile.format("%8s %8s\n", "Value", "Square"); for (int i = 1; i < 20; i++) fmtFile.format("%8d %8d\n", i, i * i); fmtFile.close();//from ww w .ja v a 2 s. co m if (fmtFile.ioException() != null) { System.out.println("File I/O Error Occurred"); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmtCon = new Formatter(System.out); Formatter fmtFile; fmtFile = new Formatter(new FileOutputStream("test.fmt")); fmtCon.format("a negative number: %(.2f\n\n", -123.34); fmtCon.format("%8s %8s\n", "Value", "Square"); for (int i = 1; i < 20; i++) fmtCon.format("%8d %8d\n", i, i * i); // write to the file. fmtFile.format("This is a negative number: %(.2f\n\n", -123.34); fmtFile.format("%8s %8s\n", "Value", "Square"); for (int i = 1; i < 20; i++) fmtFile.format("%8d %8d\n", i, i * i); fmtFile.close();/* w ww. j a v a2 s .c om*/ if (fmtFile.ioException() != null) { System.out.println("File I/O Error Occurred"); } }