From: <st...@us...> - 2009-11-12 13:42:04
|
Revision: 8033 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8033&view=rev Author: steve_l Date: 2009-11-12 13:41:46 +0000 (Thu, 12 Nov 2009) Log Message: ----------- SFOS-1368 export ExpandFully's code to save a CD to a file as a static method Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SFExpandFully.java Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SFExpandFully.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SFExpandFully.java 2009-11-12 13:35:44 UTC (rev 8032) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/SFExpandFully.java 2009-11-12 13:41:46 UTC (rev 8033) @@ -78,7 +78,8 @@ //enable stack trace logging org.smartfrog.sfcore.common.Logger.logStackTrace = true; - File srcFile, destFile; + File srcFile; + File destFile; if (args.length != 3) { usage(); ExitCodes.exitWithError(ExitCodes.EXIT_ERROR_CODE_BAD_ARGS); @@ -108,13 +109,10 @@ } else { //save the results to a string and then a file ComponentDescription description = results.cd; - StringBuilder buffer = new StringBuilder(); - buffer.append("sfConfig extends {\n"); - buffer.append(description.toString()); - buffer.append("\n}\n"); - saveTextToFile(destFile, buffer.toString()); + saveCDtoFile(description, destFile); SFSystem.sfLog().out(NAME + ": SUCCESSFUL"); ExitCodes.exitWithError(ExitCodes.EXIT_CODE_SUCCESS); + } } catch (Throwable thr) { SFSystem.sfLog().error("Exception " + thr, thr); @@ -123,7 +121,27 @@ } - private static void saveTextToFile(File destFile, String text) throws SmartFrogException { + /** + * Utility method to save a CD to a file + * @param description CD to save + * @param destFile destfile + * @throws SmartFrogException something went wrong + */ + public static void saveCDtoFile(ComponentDescription description, File destFile) throws SmartFrogException { + StringBuilder buffer = new StringBuilder(); + buffer.append("sfConfig extends {\n"); + buffer.append(description.toString()); + buffer.append("\n}\n"); + saveTextToFile(destFile, buffer.toString()); + } + + /** + * Save text to a file + * @param destFile destfile + * @param text text to save + * @throws SmartFrogException failure to write the file + */ + public static void saveTextToFile(File destFile, String text) throws SmartFrogException { Writer wout = null; try { OutputStream fout; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |