I think he means the length attribute of the array created from the split() method, used to find the last token from the array. In which case, yes. The last token will be splitString[splitString.length - 1].
split() returns a String array. You want the last element of the array.
Of course, if you just want to get the file name from a path, you should create a File object and then call its getName() method. This will be more o/s independent as you will not need to worry what the path separator is.
File.getName() might work if the thing you're talking about has a path like a file. Since it begins with http: though that looks suspicious and misleading to me.
On the other hand, the fact that this thing that looks like a URL has backslashes rather than forward slashes is also suspicious. Are you sure that's really what you want here?
If the backslashes are correct, then using split() is more complicated than it looks because \ is a special character for both Java and for regular expressions, and there are two levels of escaping required. (Yes, when you use split() you're using a regular expression.) Which means that to split over a literal \, you actually need split("\\\\"). But if it's actually / you should be using, then split("/") is sufficient. If the reasons for this are not apparent, I recommend studying regular expressions. It may be more complexity than you really need for this particular problem, but regular expressions are also very useful in general, so it's beneficial for you to learn about them eventually.
Or, you could just forget all that and use a few simple methods of the String class:
"I'm not back." - Bill Harding, Twister
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop