/**
 * Copyright (c) 2016, German Neuroinformatics Node (G-Node)
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted under the terms of the BSD License. See
 * LICENSE file in the root of the Project.
 */

package org.g_node.micro.commons;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Locale;

/**
 * Main service class for dealing with files.
 *
 * @author Michael Sonntag (sonntag@bio.lmu.de)
 */
public final class FileService {
    /**
     * Method for validating that a file actually exists.
     * @param checkFile Path and filename of the provided file.
     * @return True if the file exists, false otherwise.
     */
    public static boolean checkFile(final String checkFile) {

        return Files.exists(Paths.get(checkFile))
                && Files.exists(Paths.get(checkFile).toAbsolutePath());

    }

    /**
     * Method for validating that the provided file is of a supported file extension.
     * @param checkFile Filename of the provided file.
     * @param fileExtensions List containing all supported file extensions.
     * @return True if the file ends with a supported file extension, false otherwise.
     */
    public static boolean checkFileExtension(final String checkFile, final List<String> fileExtensions) {

        boolean correctFileType = false;

        final int i = checkFile.lastIndexOf('.');
        if (i > 0) {
            final String checkExtension = checkFile.substring(i + 1);
            correctFileType = fileExtensions.contains(checkExtension.toUpperCase(Locale.ENGLISH));
        }

        return correctFileType;
    }

    /**
     * Method for validating that the provided file is of a supported file extension.
     * @param checkFile Filename of the provided file.
     * @param fileExtension String containing the supported file extension.
     * @return True if the file ends with the supported file extension, false otherwise.
     */
    public static boolean checkFileExtension(final String checkFile, final String fileExtension) {

        boolean correctFileType = false;

        final int i = checkFile.lastIndexOf('.');
        if (i > 0) {
            final String checkExtension = checkFile.substring(i + 1);
            correctFileType = fileExtension.equals(checkExtension.toUpperCase(Locale.ENGLISH));
        }

        return correctFileType;
    }

}

@@ -329,22 +329,77 @@
 ava.
-nio.file.Files
+io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path
 ;%0Aim
@@ -2509,10 +2509,1022 @@
 %0A    %7D%0A%0A
+    /**%0A     * Creates a backup file with a timestamp and the string %22backup%22 in its name.%0A     * @param file Name of the file that is to be copied.%0A     * @param dateTimeFormatPattern Format of the timestamp, use DateTimeFormatter pattern conventions.%0A     * @return True if the file was successfully created, false, if something failed.%0A     */%0A    public static boolean createTimeStampBackupFile(final String file, final String dateTimeFormatPattern) %7B%0A        final Path mainPath = Paths.get(file);%0A        final String fileName = mainPath.getFileName().toString();%0A        final String ts = AppUtils.getTimeStamp(dateTimeFormatPattern);%0A        final String backupName = String.join(%22%22, ts, %22_backup_%22, fileName);%0A        final String backupPath = mainPath.toString().replaceFirst(fileName, backupName);%0A%0A        try %7B%0A            Files.copy(mainPath, Paths.get(backupPath));%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A        return true;%0A    %7D%0A%0A
 %7D%0A

Add createTimeStampBackupFile method