Java tutorial
//package com.java2s; import java.io.File; import java.io.IOException; import java.nio.file.Files; public class Main { private static String COMPEXP_LOG_PATH = new StringBuilder("src").append(File.separator).append("de") .append(File.separator).append("tum").append(File.separator).append("ziller").append(File.separator) .append("thesis").append(File.separator).append("thrp").append(File.separator).append("log") .append(File.separator).append("comp-experiment.xml").toString(); public static void backupComputationExperimentResults(String appendix) throws IOException { String name = COMPEXP_LOG_PATH.replace(".xml", "-" + appendix + ".xml"); while ((new File(name)).exists()) { name = name.replace(".xml", "-" + appendix + ".xml"); } Files.copy(new File(COMPEXP_LOG_PATH).toPath(), new File(name).toPath()); } }