PathUtils

Utility methods to handle paths. For example, get the name or get the parent path. 

Methods

getParent

Description:

MethodReturn valuesDescription

getParent(String path)

String

Get parent node.

path: The path of the file.

Example:

package com.openkm;

import com.openkm.util.PathUtils;

public class Test {
    public static void main(String[] args) {
        try {
            System.out.println(PathUtils.getParent("/okm:root/test.docx"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getName

Description:

MethodReturn valuesDescription

getName(String path)

String

Get name node.

path: The path of the file.

Example:

package com.openkm;

import com.openkm.util.PathUtils;

public class Test {
    public static void main(String[] args) {
        try {
            System.out.println(PathUtils.getName("/okm:root/test.docx"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getContext

Description:

MethodReturn valuesDescription

getContext(String path)

String

Get path context. For example "/okm:root/test.txt" -> "/okm:root".

path: The path of the file.

Example:

package com.openkm;

import com.openkm.util.PathUtils;

public class Test {
    public static void main(String[] args) {
        try {
            System.out.println(PathUtils.getContext("/okm:root/test.txt"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}