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

io.swagger.v3.parser.util.PathUtils Maven / Gradle / Ivy

There is a newer version: 2.0.14-OpenAPITools.org-1
Show newest version
package io.swagger.v3.parser.util;

import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;

public class PathUtils {


    public static Path getParentDirectoryOfFile(String fileStr) {
        final String fileScheme = "file:";
        Path file;
        fileStr = fileStr.replaceAll("\\\\","/");
        if (fileStr.toLowerCase().startsWith(fileScheme)) {
            file = Paths.get(URI.create(fileStr)).toAbsolutePath();
        } else {
            file = Paths.get(fileStr).toAbsolutePath();
        }
        return file.toAbsolutePath().getParent();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy