Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Let's san I have a String looks like
a/b/c/d
I need to process some job(MKCOL) for following values in a row.
a a/b a/b/c a/b/c/d
I know I can split and using them concatenating one by one.
Is there any way to do this with stream?
Sure it is:
String s = "a/b/c/d"; String[] array = s.split("/"); for (int i = 1; i <= array.length; i++) { String part = Arrays.stream(array).limit(i).collect(Collectors.joining("/")); System.out.println(part); }
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.