Java Parent Path Get getParentPath(File file, boolean wrap, boolean escape)

Here you can find the source of getParentPath(File file, boolean wrap, boolean escape)

Description

get Parent Path

License

Open Source License

Declaration

public static String getParentPath(File file, boolean wrap, boolean escape) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static String getParentPath(File file, boolean wrap, boolean escape) {
        if (file.getParent() != null) {
            return wrapAndEscape(file.getParentFile().getAbsolutePath(), wrap, escape);
        } else {//www . j  a  v a  2  s. com
            return null;
        }
    }

    private static String wrapAndEscape(String string, boolean wrap, boolean escape) {
        if (escape) {
            string = string.replaceAll(" ", "\\\\ ");
        }
        if (wrap) {
            string = "\"" + string + "\"";
        }
        return string;
    }
}

Related

  1. getParentPath()
  2. getParentPath(String absolutePath)
  3. getParentPath(String filePath)
  4. getParentPath(String fullpath)
  5. getParentPath(String path)