Java Path Delete nio deleteFile(Path path)

Here you can find the source of deleteFile(Path path)

Description

Deletes a file relative to the upload path

License

Open Source License

Parameter

Parameter Description
path The file path to delete

Declaration

public static void deleteFile(Path path) 

Method Source Code

//package com.java2s;
/* FileHelper.java/*from   ww  w  . jav  a2s .co m*/
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Copyright ? 2014-2015 Universiteit Gent
 * 
 * This file is part of the Degage Web Application
 * 
 * Corresponding author (see also AUTHORS.txt)
 * 
 * Kris Coolsaet
 * Department of Applied Mathematics, Computer Science and Statistics
 * Ghent University 
 * Krijgslaan 281-S9
 * B-9000 GENT Belgium
 * 
 * The Degage Web Application is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * The Degage Web Application is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with the Degage Web Application (file LICENSE.txt in the
 * distribution).  If not, see http://www.gnu.org/licenses/.
 */

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    private static String UPLOAD_FOLDER;

    /**
     * Deletes a file relative to the upload path
     *
     * @param path The file path to delete
     * @returns Whether the delete operation was successfull
     */
    public static void deleteFile(Path path) {
        try {
            Files.delete(Paths.get(UPLOAD_FOLDER).resolve(path));
        } catch (IOException ex) {
            // ignore
        }
    }
}

Related

  1. deleteContent(Path directory)
  2. deleteEmptyDirsUpTo(Path from, Path to)
  3. deleteEmptyParentDirs(Path pkgDirPath, Path repoPath)
  4. deleteFile(Path p)
  5. deleteFile(Path path)
  6. deleteFile(Path path)
  7. deleteFile(String filePath)
  8. deleteFile(String path)
  9. deleteFilesIfExist(Path... files)