mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 07:20:53 +07:00
19 lines
557 B
Plaintext
19 lines
557 B
Plaintext
import java.io.File;
|
|
|
|
class Main {
|
|
String getParent(String path) {
|
|
if (path == null) {
|
|
throw new NullPointerException();
|
|
}
|
|
String path1 = fs.normalize(path);
|
|
int prefixLength = fs.prefixLength(path1);
|
|
int index = path1.lastIndexOf(File.separatorChar);
|
|
if (index < prefixLength) {
|
|
if ((prefixLength > 0) && (path1.length() > prefixLength))
|
|
return path1.substring(0, prefixLength);
|
|
return null;
|
|
}
|
|
return path1.substring(0, index);
|
|
}
|
|
}
|