org.openstreetmap.osmosis.core.util
Class AtomicFileCreator

java.lang.Object
  extended by org.openstreetmap.osmosis.core.util.AtomicFileCreator

public class AtomicFileCreator
extends java.lang.Object

Supports the creation of files in an atomic fashion. Internally it creates files using a temporary filename, then renames them to the final file name.


Constructor Summary
AtomicFileCreator(java.io.File file)
          Creates a new instance.
 
Method Summary
 boolean exists()
          Checks if either one of the main or temporary files currently exists.
 java.io.File getFile()
          Returns the file represented by this class.
 java.io.File getTmpFile()
          Returns the temporary file used during file generation.
 void renameTmpFileToCurrent()
          Renames the new temporary file to the current file deleting the current file if it exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtomicFileCreator

public AtomicFileCreator(java.io.File file)
Creates a new instance.

Parameters:
file - The file to be created.
Method Detail

exists

public boolean exists()
Checks if either one of the main or temporary files currently exists.

Returns:
True if a file exists, false otherwise.

renameTmpFileToCurrent

public void renameTmpFileToCurrent()
Renames the new temporary file to the current file deleting the current file if it exists.


getTmpFile

public java.io.File getTmpFile()
Returns the temporary file used during file generation. This file is written first, and then renamed to the real file name when complete.

Returns:
The temporary file name.

getFile

public java.io.File getFile()
Returns the file represented by this class. This file is not written directly, instead a temporary file is created and then renamed to this file.

Returns:
The file name.