Hi, I what to be able to get the "basename" of a String that maybe be a file's name. I know how to do this in a shell script which I'll will post as demostration of what I want to be able to do in Java ...
The File object is used to manipulate files and directories. Use getName() to get the filename in the format you want. The code below doesn't do exactly what you want (I figure you can do some work yourself , but it should give you examples of the classes and methods you could use. Cheers,
Lemme see if I hear your problem ... you have a string which might contain d:\path\name.ext and you want to extract just name.ext? Look into lastIndexOf() to find the last slash, and then substring to get the name.ext that follows. Be sure to try it on a string with no slashes at all. Maybe do all this once for forward slash / and again for back slash \.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi