About checking for the existence of data
Programs often use paths to data, which can be problematic if the data being referenced does not exist. Data can be deleted or moved between executions of a script and causes errors if the path is used as a geoprocessing tool parameter. If there is a possibility of a referenced dataset not existing during a program's execution, use the geoprocessor's Exists method.
The function returns a Boolean value for the existence of a dataset or object at the time of execution. Objects, such as a spatial reference, or any other object managed by the geoprocessor, can also be used as input to the Exists method. The Exists method works with any type of data available in ArcCatalog or with any system file or folder. An ArcCatalog path must be used for this and any other method of the geoprocessor when referring to geographic information system (GIS) data. If the data resides in an enterprise geodatabase, the name must be fully qualified. See the following code example:[Java]
boolean dtExists = gp.exists("C:/Data/PortlandOR.gdb/downtown", null);
The default behavior for all tools is to not overwrite any output that exists. This behavior can be changed by changing the OverWriteOutput setting to true. Attempting to overwrite when the OverWriteOutput option is false, causes a tool to fail.
If an application is viewing or using the data, there may be a schema lock. If this is the case, you cannot overwrite the data.
See the following code example:[Java]