package output; import game.Config; public class StoreFileWriter { private final static String storePath = Config.getBlackBoardPath() + "/store.xml"; //address of store.xml private static StoreFileWriter reference; //reference to StoreFileWriter singleton /** * default constructor */ private StoreFileWriter() { reference = null; } /** * Initialize a new StoreFileWriter if one does not exist * @return StoreFileWriter */ public static StoreFileWriter initialize() { if( reference == null ) return new StoreFileWriter(); else return reference; } /** * get the StoreFileWriter * * @return StoreFileWriter */ public static StoreFileWriter getStoreFileWriter() { return reference; } /** * write the text to the store file * * @param pText : text to be written */ public void writeFile( String pText ) { //get an XMLFileWriter XMLFileWriter writer = XMLFileWriter.initialize(); //if an error occurs writing the document, throw an exception writer.writeFile( storePath, pText ); } }