MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getLastPathComponent

Method getLastPathComponent

src/main/java/gate/util/Files.java:90–98  ·  view source on GitHub ↗

It returns the last component in a file path. It takes E.g: d:/tmp/file.txt and returns file.txt

(String path)

Source from the content-addressed store, hash-verified

88 * It takes E.g: d:/tmp/file.txt and returns file.txt
89 */
90 public static String getLastPathComponent(String path){
91 if(path == null || path.length() == 0) return "";
92 //we should look both for "/" and "\" as on windows the file separator is"\"
93 //but a path coming from an URL will be separated by "/"
94 int index = path.lastIndexOf('/');
95 if(index == -1) index = path.lastIndexOf('\\');
96 if(index == -1) return path;
97 else return path.substring(index + 1);
98 }// getLastPathComponent()
99
100 /** Get a string representing the contents of a text file. */
101 public static String getString(String fileName) throws IOException {

Callers 15

runMethod · 0.95
nodeForRowMethod · 0.80
mouseClickedMethod · 0.80
showDialogMethod · 0.80
treeWillExpandMethod · 0.80
createTransferableMethod · 0.80
processMouseEventMethod · 0.80
valueChangedMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 2

lengthMethod · 0.45
lastIndexOfMethod · 0.45

Tested by

no test coverage detected