question: private static synchronized void saveXML ( Element rootElement , File containerFile ) throws IOException { try { String filePath = containerFile . getCanonicalPath ( ) ; String filePathWithoutExtention = filePath . substring ( 0 , filePath . lastIndexOf ( '.' ) ) ; File oldFile = new File ( filePathWithoutExtention + ".old" ) ; if ( oldFile . exists ( ) ) oldFile . delete ( ) ; else containerFile . renameTo ( oldFile ) ; PrintStream attrStream = new PrintStream ( new FileOutputStream ( filePath ) ) ; JSpaceUtilities . domWriter ( rootElement , attrStream , "" ) ; attrStream . close ( ) ; } catch ( FileNotFoundException ex ) { if ( _logger . isLoggable ( Level . SEVERE ) ) { _logger . log ( Level . SEVERE , "FileNotFoundException: " + ex . toString ( ) , ex ) ; } } }
target:  Every change in container the container xml file will be updating be this method. On every update current file will be renamed to <%filename%>.old and the new one will be <%filename%>.xml