1public static Writer createOutputWriter(String fileNm) {
2 OutputStream os;
3 if (fileNm.equals("") ) { // No file name provided, write to console
4 os = System.out;
5 }
6 // File name provided, write to this file name
7 else {
8 try {
9 os = new FileOutputStream(fileNm);
10 }
11 catch (FileNotFoundException fe) {
12 System.out.println("File not found " + fe.toString());
13 }
14 }
15 return new BufferedWriter(new OutputStreamWriter(os));
16}
17