All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.nichetoolkit.rest.util.PathUtils Maven / Gradle / Ivy

The newest version!
package io.github.nichetoolkit.rest.util;

import io.github.nichetoolkit.rest.constant.UtilConstants;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * PathUtils
 * 

The path utils class.

* @author Cyan ([email protected]) * @since Jdk1.8 */ public class PathUtils { /** * getRootPath *

The get root path getter method.

* @return {@link java.lang.String}

The get root path return object is String type.

* @see java.lang.String */ public static String getRootPath() { File file; try { file = new File(ResourceUtils.getURL(UtilConstants.ROOT_PREFIX).getPath()); if(!file.exists()) { file = new File(UtilConstants.EMPTY_PREFIX); } } catch (FileNotFoundException ignoredException) { file = new File(UtilConstants.EMPTY_PREFIX); } return file.getAbsolutePath(); } /** * getChildPath *

The get child path getter method.

* @param childName {@link java.lang.String}

The child name parameter is String type.

* @return {@link java.lang.String}

The get child path return object is String type.

* @see java.lang.String * @see java.lang.SuppressWarnings */ @SuppressWarnings("ResultOfMethodCallIgnored") public static String getChildPath(final String childName) { String rootPath = getRootPath(); String staticPath = UtilConstants.STATIC_PREFIX.concat(File.separator).concat(childName).concat(File.separator); File file = new File(rootPath, staticPath); if(!file.exists()) { file.mkdirs(); } return file.getAbsolutePath(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy