Reputation: 382
There is path like this /root/folder1/subfolder1/subfolder2. Using split() method it generates empty first element. How can first empty string be avoided ?
Upvotes: 0
Views: 39
Reputation: 159086
Strip the leading /
before calling split("/")
.
Use e.g. replaceFirst("^/", "")
to do that.
Upvotes: 2