question: private static void saveTemplate ( File parentDir , FileTemplateBase template , final String lineSeparator ) throws IOException { final File templateFile = new File ( parentDir , encodeFileName ( template . getName ( ) , template . getExtension ( ) ) ) ; FileOutputStream fileOutputStream ; try { fileOutputStream = new FileOutputStream ( templateFile ) ; } catch ( FileNotFoundException e ) { FileUtil . delete ( templateFile ) ; fileOutputStream = new FileOutputStream ( templateFile ) ; } OutputStreamWriter outputStreamWriter = new OutputStreamWriter ( fileOutputStream , CharsetToolkit . UTF8_CHARSET ) ; String content = template . getText ( ) ; if ( ! lineSeparator . equals ( "\n" ) ) { content = StringUtil . convertLineSeparators ( content , lineSeparator ) ; } outputStreamWriter . write ( content ) ; outputStreamWriter . close ( ) ; fileOutputStream . close ( ) ; }
target:  Save template to file. If template is new, it is saved to specified directory. Otherwise it is saved to file from which it was read. If template was not modified, it is not saved. todo: review saving algorithm