KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > util > export > CSVFileTools


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.util.export;
8
9 import java.io.File JavaDoc;
10 import java.io.FileWriter JavaDoc;
11 import java.io.IOException JavaDoc;
12 import java.util.ResourceBundle JavaDoc;
13
14 import org.apache.log4j.Logger;
15 import org.ejtools.util.FileTools;
16
17 /**
18  * Description of the Class
19  *
20  * @author Laurent Etiemble
21  * @version $Revision: 1.2 $
22  */

23 public class CSVFileTools extends FileTools
24 {
25    /** Description of the Field */
26    private static Logger logger = Logger.getLogger(CSVFileTools.class);
27    /** Description of the Field */
28    private static ResourceBundle JavaDoc resources = ResourceBundle.getBundle("org.ejtools.util.Resources");
29    /** Description of the Field */
30    public final static SimpleFileFilter CSV_FILE_FILTER = new FileTools.SimpleFileFilter(".csv", resources.getString("csv.file.dialog.extension.description"));
31
32
33    /** Constructor for the FileUtil object */
34    protected CSVFileTools() { }
35
36
37    /**
38     * Description of the Method
39     *
40     * @param output Description of the Parameter
41     * @param content Description of the Parameter
42     */

43    public static void exportAsCVS(StringBuffer JavaDoc content, File JavaDoc output)
44    {
45       try
46       {
47          FileWriter JavaDoc writer = new FileWriter JavaDoc(output);
48          writer.write(content.toString());
49          writer.flush();
50          writer.close();
51       }
52       catch (IOException JavaDoc ioe)
53       {
54          logger.error("Can't export content as CSV", ioe);
55       }
56    }
57 }
58
Popular Tags