Here you can find the source of createDirectoriesForFile(Path file)
Parameter | Description |
---|---|
file | the file for which all needed directories should be created |
Parameter | Description |
---|---|
RuntimeException | if the directories could not be created |
public static void createDirectoriesForFile(Path file)
//package com.java2s; /*/* w ww . j av a2s. co m*/ * BasePlugin * Copyright (C) 2014 Viciouss <http://www.doncarnage.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; public class Main { /** * Creates all missing directories for the current path. This is to prevent an exception that would get thrown if the path contains a file in a directory * that does not yet exist as private logging files could and actually get by default stored in the log files subdirectory of the plugins own directory. * * @param file the file for which all needed directories should be created * @throws RuntimeException if the directories could not be created */ public static void createDirectoriesForFile(Path file) { Path parent = file.getParent(); try { Files.createDirectories(parent); } catch (IOException e) { throw new RuntimeException(e); } } }