public void closeAndRename ( File archiveDirectory ) throws JournalException { try { xmlReader . close ( ) ; fileReader . close ( ) ; File archiveFile = new File ( archiveDirectory , file . getName ( ) ) ; /* * java.io.File.renameTo() has a known bug when working across * file-systems, see: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4073756 So * instead of this call: file.renameTo(archiveFile); We use the * following line, and check for exception... */ try { FileMovingUtil . move ( file , archiveFile ) ; } catch ( IOException e ) { throw new JournalException ( "Failed to rename file from '" + file . getPath ( ) + "' to '" + archiveFile . getPath ( ) + "'" , e ) ; } } catch ( XMLStreamException e ) { throw new JournalException ( e ) ; } catch ( IOException e ) { throw new JournalException ( e ) ; } }
When we have processed the file move it to the archive directory .