1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package convwatch; 29 30 import java.io.File; 31 import java.io.FileWriter; 32 33 public class LISTOutputter 34 { 35 FileWriter m_aOut; 36 String m_sFilename; 37 38 /** 39 * ls is the current line separator (carridge return) 40 */ 41 String ls; 42 43 public static LISTOutputter create( String _sOutputPath, String _sFilename) 44 { 45 FileHelper.makeDirectories("", _sOutputPath); 46 LISTOutputter a = new LISTOutputter(); 47 String fs = System.getProperty("file.separator"); 48 String sFilename = _sOutputPath + fs + _sFilename; 49 50 try 51 { 52 File outputFile = new File(sFilename); 53 a.m_aOut = new FileWriter(outputFile.toString()); 54 a.ls = System.getProperty("line.separator"); 55 } 56 catch (java.io.IOException e) 57 { 58 e.printStackTrace(); 59 GlobalLogWriter.get().println("ERROR: Can't create LIST Outputter"); 60 return null; 61 } 62 a.m_sFilename = sFilename; 63 64 return a; 65 } 66 public String getFilename() {return m_sFilename;} 67 68 public void createHeader() 69 { 70 try 71 { 72 m_aOut.write("# This file is automatically created by a convwatch run" + ls); 73 m_aOut.write("# " + ls); 74 } 75 catch (java.io.IOException e) 76 { 77 } 78 } 79 80 public void writeValue(String _sValue) 81 { 82 try 83 { 84 m_aOut.write(_sValue + ls); 85 m_aOut.flush(); 86 } 87 catch (java.io.IOException e) 88 { 89 } 90 } 91 92 public void close() 93 { 94 try 95 { 96 m_aOut.flush(); 97 m_aOut.close(); 98 } 99 catch (java.io.IOException e) 100 { 101 } 102 } 103 104 } 105