Java: How to copy automatically a file each time one is generated in a folder? <p>I am asking for a Java code.</p> <p>An ERP generates XML files in a folder, and each one has a different name.</p> <p>For data extraction, I need to:</p> <p><strong>If</strong> new file is generated:</p> <ol> <li><p>Copy file from the main folder to a secondary folder</p></li> <li><p>Rename this file under "temp"</p></li> <li><p>Extract data with an ETL (Talend) from "temp"</p></li> <li><p>Delete the file "temp"</p></li> </ol> <p>My question is: <strong>How to capture automaticaly a file with Java in order to copy or rename it each time one is generated?</strong></p> <p>Thanks</p>