0

There is path like this /root/folder1/subfolder1/subfolder2. Using split() method it generates empty first element. How can first empty string be avoided ?

1
  • You need to be more specific. What value did you pass to split() A code fragment would help make your question more specific and easier to understand Commented Sep 28, 2020 at 6:10

1 Answer 1

2

Strip the leading / before calling split("/").

Use e.g. replaceFirst("^/", "") to do that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.